|
|
@@ -1,33 +1,103 @@ |
|
|
after "deploy:stop", "clockwork:stop" |
|
|
after "deploy:start", "clockwork:start" |
|
|
after "deploy:restart", "clockwork:restart" |
|
|
namespace :workers do |
|
|
namespace :clockwork do |
|
|
desc "Stop clockwork" |
|
|
task :stop do |
|
|
on roles(:app) do |
|
|
within release_path do |
|
|
with rails_env: fetch(:rails_env) do |
|
|
execute :bundle, :exec, :clockworkd, "-c lib/clockwork.rb --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} stop" |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
set :cw_log_file, "#{shared_path}/log/clockwork.log" |
|
|
set :cw_pid_file, "#{shared_path}/tmp/pids/clockwork.pid" |
|
|
desc "Clockwork status" |
|
|
task :status do |
|
|
on roles(:app) do |
|
|
within release_path do |
|
|
with rails_env: fetch(:rails_env) do |
|
|
execute :bundle, :exec, :clockworkd, "-c lib/clockwork.rb --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} status" |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
namespace :clockwork do |
|
|
desc "Stop clockwork" |
|
|
task :stop, :roles => :app, :on_no_matching_servers => :continue do |
|
|
run "daemon --inherit --name=clockwork --env='#{rails_env}' --output=#{cw_log_file} --pidfile=#{cw_pid_file} -D #{current_path} --stop || true" |
|
|
end |
|
|
desc "Start clockwork" |
|
|
task :start do |
|
|
on roles(:app) do |
|
|
within release_path do |
|
|
with rails_env: fetch(:rails_env) do |
|
|
execute :bundle, :exec, :clockworkd, "-c lib/clockwork.rb --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} start" |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
desc "Clockwork status" |
|
|
task :status, :roles => :app, :on_no_matching_servers => :continue do |
|
|
run "daemon --inherit --name=clockwork --env='#{rails_env}' --output=#{cw_log_file} --pidfile=#{cw_pid_file} -D #{current_path} --verbose --running || true" |
|
|
end |
|
|
desc "Restart clockwork" |
|
|
task :restart do |
|
|
on roles(:app) do |
|
|
within release_path do |
|
|
with rails_env: fetch(:rails_env) do |
|
|
execute :bundle, :exec, :clockworkd, "-c lib/clockwork.rb --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} restart" |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
desc "Start clockwork" |
|
|
task :start, :roles => :app, :on_no_matching_servers => :continue do |
|
|
run "daemon --inherit --name=clockwork --env='#{rails_env}' --output=#{cw_log_file} --pidfile=#{cw_pid_file} -D #{current_path} -- bundle exec clockwork lib/clockwork.rb" |
|
|
end |
|
|
def cw_log_dir |
|
|
"#{shared_path}/log" |
|
|
end |
|
|
def cw_pid_dir |
|
|
"#{shared_path}/tmp/pids" |
|
|
end |
|
|
|
|
|
desc "Restart clockwork" |
|
|
task :restart, :roles => :app, :on_no_matching_servers => :continue do |
|
|
stop |
|
|
start |
|
|
|
|
|
def rails_env |
|
|
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : '' |
|
|
end |
|
|
end |
|
|
|
|
|
def rails_env |
|
|
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : '' |
|
|
namespace :delayed_job do |
|
|
def args |
|
|
fetch(:delayed_job_args, "") #Useful for queuing on specific servers |
|
|
end |
|
|
|
|
|
def delayed_job_roles |
|
|
fetch(:delayed_job_server_role, :app) |
|
|
end |
|
|
|
|
|
desc 'Stop the delayed_job process' |
|
|
task :stop do |
|
|
on roles(delayed_job_roles) do |
|
|
within release_path do |
|
|
with rails_env: fetch(:rails_env) do |
|
|
execute :bundle, :exec, :'script/delayed_job', :stop |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
desc 'Start the delayed_job process' |
|
|
task :start do |
|
|
on roles(delayed_job_roles) do |
|
|
within release_path do |
|
|
with rails_env: fetch(:rails_env) do |
|
|
execute :bundle, :exec, :'script/delayed_job', args, :start |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
desc 'Restart the delayed_job process' |
|
|
task :restart do |
|
|
on roles(delayed_job_roles) do |
|
|
within release_path do |
|
|
with rails_env: fetch(:rails_env) do |
|
|
execute :bundle, :exec, :'script/delayed_job', args, :restart |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
end |
|
|
end |