diff --git a/config/deploy-example.rb b/config/deploy-example.rb index 7454fe0a7..655838070 100644 --- a/config/deploy-example.rb +++ b/config/deploy-example.rb @@ -17,6 +17,7 @@ set :repository, 'https://github.com/domify/registry' # dev repo set :branch, 'master' set :rails_env, 'alpha' set :que_restart, true +set :cron_group, 'registry' # alpha branch, only use for heavy debugging task :epp do @@ -36,6 +37,7 @@ task :registrar do set :branch, 'master' set :rails_env, 'alpha' set :que_restart, false + set :cron_group, 'registrar' end # alpha branch, only use for heavy debugging @@ -46,6 +48,7 @@ task :registrant do set :branch, 'master' set :rails_env, 'alpha' set :que_restart, false + set :cron_group, 'registrant' end # staging @@ -66,6 +69,7 @@ task :eppst do set :branch, 'staging' set :rails_env, 'staging' set :que_restart, false + set :cron_group, 'epp' end # staging @@ -76,6 +80,7 @@ task :registrarst do set :branch, 'staging' set :rails_env, 'staging' set :que_restart, false + set :cron_group, 'registrar' end # staging @@ -86,6 +91,7 @@ task :registrantst do set :branch, 'staging' set :rails_env, 'staging' set :que_restart, false + set :cron_group, 'registrant' end # production @@ -106,6 +112,7 @@ task :epppr do set :branch, 'master' set :rails_env, 'production' set :que_restart, false + set :cron_group, 'epp' end # production @@ -116,6 +123,7 @@ task :registrarpr do set :branch, 'master' set :rails_env, 'production' set :que_restart, false + set :cron_group, 'registrar' end # production @@ -126,6 +134,7 @@ task :registrantpr do set :branch, 'master' set :rails_env, 'production' set :que_restart, false + set :cron_group, 'registrant' end # Manually create these paths in shared/ (eg: shared/config/database.yml) in your server. @@ -234,7 +243,7 @@ end desc 'Restart que server' task que_restart: :environment do - queue "/etc/init.d/que restart" + queue "/etc/init.d/que restart" end namespace :cron do @@ -251,6 +260,32 @@ namespace :cron do end end +namespace :whenever do + name = -> { "#{domain}_#{rails_env}" } + + desc "Clear crontab" + task clear: :environment do + queue %( + echo "-----> Clear crontab for #{name.call}" + #{echo_cmd %(cd #{deploy_to!}/#{current_path!} ; #{bundle_bin} exec whenever --clear-crontab #{name.call} --set 'environment=#{rails_env}&path=#{deploy_to!}/#{current_path!}&cron_group=#{cron_group}')} + ) + end + desc "Update crontab" + task update: :environment do + queue %( + echo "-----> Update crontab for #{name.call}" + #{echo_cmd %(cd #{deploy_to!}/#{current_path!} ; #{bundle_bin} exec whenever --update-crontab #{name.call} --set 'environment=#{rails_env}&path=#{deploy_to!}/#{current_path!}&cron_group=#{cron_group}')} + ) + end + desc "Write crontab" + task write: :environment do + queue %( + echo "-----> Update crontab for #{name.call}" + #{echo_cmd %(cd #{deploy_to!}/#{current_path!} ; #{bundle_bin} exec whenever --write-crontab #{name.call} --set 'environment=#{rails_env}&path=#{deploy_to!}/#{current_path!}&cron_group=#{cron_group}')} + ) + end +end + # For help in making your deploy script, see the Mina documentation: # # - http://nadarei.co/mina