This repository has been archived by the owner on Oct 26, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
whenever.rb
55 lines (48 loc) · 2.51 KB
/
whenever.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# encoding: utf-8
#
# Tasks:
#
# - vlad:whenever:update_crontab
# - vlad:whenever:clear_crontab
namespace :vlad do
namespace :whenever do
set(:whenever_command) { "#{bundle_cmd} exec whenever" }
set(:whenever_identifier) { application }
set(:whenever_environment) { rails_env }
set(:whenever_variables) { "environment=#{whenever_environment}" }
set(:whenever_update_flags) { "--update-crontab #{whenever_identifier} --set #{whenever_variables}" }
set(:whenever_clear_flags) { "--clear-crontab #{whenever_identifier}" }
desc <<-DESC
Update application's crontab entries using Whenever. You can configure \
the command used to invoke Whenever by setting the :whenever_command \
variable, which can be used with Bundler to set the command to \
"bundle exec whenever". You can configure the identifier used by setting \
the :whenever_identifier variable, which defaults to the same value configured \
for the :application variable. You can configure the environment by setting \
the :whenever_environment variable, which defaults to the same value \
configured for the :rails_env variable which itself defaults to "production". \
Finally, you can completely override all arguments to the Whenever command \
by setting the :whenever_update_flags variable. Additionally you can configure \
which servers the crontab is updated on by setting the :whenever_roles variable.
DESC
remote_task :update_crontab, :roles => :app do
puts '[Whenever] Update crontab'
run "cd #{current_path} && #{whenever_command} #{whenever_update_flags}"
end
desc <<-DESC
Clear application's crontab entries using Whenever. You can configure \
the command used to invoke Whenever by setting the :whenever_command \
variable, which can be used with Bundler to set the command to \
"bundle exec whenever". You can configure the identifier used by setting \
the :whenever_identifier variable, which defaults to the same value configured \
for the :application variable. Finally, you can completely override all \
arguments to the Whenever command by setting the :whenever_clear_flags variable. \
Additionally you can configure which servers the crontab is cleared on by setting \
the :whenever_roles variable.
DESC
remote_task :clear_crontab, :roles => :app do
puts '[Whenever] Clear crontab'
run "cd #{current_path} && #{whenever_command} #{whenever_clear_flags}"
end
end
end