Commit a6c41c00 by Karl Kloppenborg

Adding in worker support

parent 6ada9cf5
......@@ -9,6 +9,8 @@ namespace :load do
# set :sneakers_timeout, -> { 10 }
set :sneakers_role, -> { :app }
set :sneakers_processes, -> { 1 }
set :sneakers_workers, -> { false } # if this is false it will cause Capistrano to exit
set :sneakers_run_config, -> { false } # if this is true sneakers will run with preconfigured /config/initializers/sneakers.rb
# Rbenv and RVM integration
set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w(sneakers))
set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w(sneakers))
......@@ -86,6 +88,15 @@ namespace :sneakers do
def start_sneakers(pid_file, idx = 0)
args = []
if fetch(:sneakers_run_config) == true
# Use sneakers configuration prebuilt in
raise "[ set :workers, ['worker1', 'workerN'] ] not configured properly, please configure the workers you wish to use" if fetch(:sneakers_workers).nil? or !fetch(:sneakers_workers).kind_of Array
workers = fetch(:sneakers_workers).compact.join(',')
raise "Workers = #{workers}"
execute :bundle, :exec, :sneakers, args.compact.join(' ')
else
# Using custom sneakers setup
args.push "--index #{idx}"
args.push "--pidfile #{pid_file}"
args.push "--environment #{fetch(:sneakers_env)}"
......@@ -113,6 +124,7 @@ namespace :sneakers do
execute :bundle, :exec, :sneakers, args.compact.join(' ')
end
end
end
task :add_default_hooks do
after 'deploy:starting', 'sneakers:quiet'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment