Skip to content

Instantly share code, notes, and snippets.

@fred
Forked from vjfrancois/clockwork.cap
Created April 22, 2014 11:13
Show Gist options
  • Select an option

  • Save fred/11174610 to your computer and use it in GitHub Desktop.

Select an option

Save fred/11174610 to your computer and use it in GitHub Desktop.
after "deploy:stop", "clockwork:stop"
after "deploy:start", "clockwork:start"
after "deploy:restart", "clockwork:restart"
set :cw_log_file, "#{shared_path}/log/clockwork.log"
set :cw_pid_file, "#{shared_path}/tmp/pids/clockwork.pid"
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 "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 "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
desc "Restart clockwork"
task :restart, :roles => :app, :on_no_matching_servers => :continue do
stop
start
end
def rails_env
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment