diff --git a/config/defaults.yml b/config/defaults.yml index 6bdaaf74b93d167ec742cd96a1db8777f60deec2..cf65086eee748d0d72c1d05901c9a15feac0c77b 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -22,6 +22,8 @@ defaults: region: image_redirect_url: pubsub_server: 'https://pubsubhubbub.appspot.com/' + unicorn: + embed_resque_worker: false privacy: jquery_cdn: true google_analytics_key: diff --git a/config/diaspora.yml.example b/config/diaspora.yml.example index 83cbf656885ad561261da7310f5fe5ef8990d009..24a7c84ec9437d16945cb21616fb88e7d4c1cda9 100644 --- a/config/diaspora.yml.example +++ b/config/diaspora.yml.example @@ -99,7 +99,11 @@ configuration: ## Diaspora is only tested against this default pubsub server. ## You likely don't want to change this. #pubsub_server: 'https://pubsubhubbub.appspot.com/' - + + unicorn: + ## Embed a resque worker inside the unicorn process, useful for + ## minimal Heroku setups + #embed_resque_worker: true ## Settings probably affecting the privacy of your users privacy: diff --git a/config/unicorn.rb b/config/unicorn.rb index 97a8d38895bf4b7d0710331c153ad7d51eed4ab4..0f998c0287e817459863f5fc61a9a86024882ecb 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -12,6 +12,8 @@ preload_app true # How long to wait before killing an unresponsive worker timeout 30 +@resque_pid = nil + #pid '/var/run/diaspora/diaspora.pid' #listen '/var/run/diaspora/diaspora.sock', :backlog => 2048 @@ -29,6 +31,12 @@ before_fork do |server, worker| if !AppConfig.single_process_mode? Resque.redis.client.disconnect end + + if AppConfig.environment.unicorn.embed_resque_worker? + # Clean up Resque workers killed by previous deploys/restarts + Resque.workers.each { |w| w.unregister_worker } + @resque_pid ||= spawn('bundle exec rake resque:work QUEUES=*') + end old_pid = '/var/run/diaspora/diaspora.pid.oldbin' if File.exists?(old_pid) && server.pid != old_pid