Created
February 11, 2011 08:10
-
-
Save tosch/822065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' # or better use Bundler | |
require 'ruote' | |
require 'ruote/storage/fs_storage' | |
class WorkerInstance | |
def initialize(storage = Ruote::FsStorage.new(File.join(File.dirname(__FILE__), 'ruote_work'))) | |
@storage, @worker = storage, Ruote::Worker.new(storage) | |
end | |
def run! | |
trap_signals | |
@worker.run | |
end | |
def stop! | |
@worker.context.shutdown | |
end | |
private | |
def trap_signals | |
%w{TERM INT}.each do |signal| | |
Signal.trap(signal) do # you could trap other signals as well | |
stop! | |
exit | |
end | |
end | |
end | |
end | |
WorkerInstance.new.run! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'daemons' | |
Daemons.run File.join(File.dirname(__FILE__), 'start_ruote_worker.rb'), | |
:app_name => "ruote_worker", | |
:dir_mode => :script, | |
:dir => '../tmp/pids', | |
:multiple => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment