Class: Faktory::Launcher
- Inherits:
-
Object
- Object
- Faktory::Launcher
- Includes:
- Util
- Defined in:
- lib/faktory/launcher.rb
Constant Summary collapse
- PROCTITLES =
[]
Constants included from Util
Instance Attribute Summary collapse
-
#manager ⇒ Object
Returns the value of attribute manager.
Instance Method Summary collapse
- #heartbeat ⇒ Object
-
#initialize(options) ⇒ Launcher
constructor
A new instance of Launcher.
-
#quiet ⇒ Object
Stops this instance from processing any more jobs,.
- #run ⇒ Object
-
#stop ⇒ Object
Shuts down the process.
- #stopping? ⇒ Boolean
Methods included from Util
#fire_event, #hostname, #identity, #logger, #process_nonce, #safe_thread, #server, #watchdog
Methods included from ExceptionHandler
Constructor Details
Instance Attribute Details
#manager ⇒ Object
Returns the value of attribute manager.
9 10 11 |
# File 'lib/faktory/launcher.rb', line 9 def manager @manager end |
Instance Method Details
#heartbeat ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/faktory/launcher.rb', line 47 def heartbeat title = ['faktory-worker', Faktory::VERSION, @options[:tag]].compact.join(" ") PROCTITLES << proc { title } PROCTITLES << proc { "[#{Processor.busy_count} of #{@options[:concurrency]} busy]" } PROCTITLES << proc { "stopping" if stopping? } loop do $0 = PROCTITLES.map {|p| p.call }.join(" ") begin Faktory.server {|c| c.beat } rescue => ex # best effort, try again in a few secs end sleep 10 end end |
#quiet ⇒ Object
Stops this instance from processing any more jobs,
23 24 25 26 |
# File 'lib/faktory/launcher.rb', line 23 def quiet @done = true @manager.quiet end |
#run ⇒ Object
17 18 19 20 |
# File 'lib/faktory/launcher.rb', line 17 def run @thread = safe_thread("heartbeat", &method(:heartbeat)) @manager.start end |
#stop ⇒ Object
Shuts down the process. This method does not return until all work is complete and cleaned up. It can take up to the timeout to complete.
31 32 33 34 35 36 37 |
# File 'lib/faktory/launcher.rb', line 31 def stop deadline = Time.now + @options[:timeout] @done = true @manager.quiet @manager.stop(deadline) end |
#stopping? ⇒ Boolean
39 40 41 |
# File 'lib/faktory/launcher.rb', line 39 def stopping? @done end |