Created
June 24, 2013 03:07
-
-
Save kain-jy/5847528 to your computer and use it in GitHub Desktop.
resque-web in /queue directory with unicorn
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 'logger' | |
require 'resque/server' | |
use Rack::ShowExceptions | |
Resque.redis = Redis.new(:host => "HOST", :port => 6379, :password => "PASS") | |
run Rack::URLMap.new \ | |
"/queue" => Resque::Server.new |
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
# unicron.conf | |
worker_processes 1 | |
working_directory '/path/to/directory' | |
pid '/path/to/queue.pid' | |
listen '/path/to/queue.sock' | |
stderr_path '/path/to/queue.log' | |
preload_app true | |
before_fork do |server, worker| | |
old_pid = "#{server.config[:pid]}.oldbin" | |
if old_pid != server.pid | |
begin | |
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU | |
Process.kill(sig, File.read(old_pid).to_i) | |
rescue Errno::ENOENT, Errno::ESRCH | |
end | |
end | |
sleep 1 | |
end | |
after_fork do |server, worker| | |
addr = "127.0.0.1:#{4423 + worker.nr}" | |
server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => 1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment