forked from mina-deploy/mina-whenever
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mina-deploy#13 Signed-off-by: Laurent Vallar <[email protected]>
- Loading branch information
Showing
2 changed files
with
10 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
set :whenever_name, -> { "#{fetch(:domain)}_#{fetch(:rails_env)}" } | ||
set :whenever_environment_variable, -> { fetch(:environment_variable) || 'RAILS_ENV' } | ||
set :whenever_environment, -> { fetch(fetch(:environment_variable).downcase.to_sym) } | ||
set :whenever_name, -> { "#{fetch(:domain)}_#{fetch(:whenever_environment)}" } | ||
|
||
namespace :whenever do | ||
desc 'Clear crontab' | ||
task clear: :environment do | ||
comment "Clear contrab for #{fetch(:whenever_name)}" | ||
in_path fetch(:current_path) do | ||
command "#{fetch(:bundle_bin)} exec whenever --clear-crontab #{fetch(:whenever_name)} --set 'environment=#{fetch(:rails_env)}&path=#{fetch(:current_path)}'" | ||
command "#{fetch(:bundle_bin)} exec whenever --clear-crontab #{fetch(:whenever_name)} --set 'environment_variable=#{fetch(:whenever_environment_variable)}&environment=#{fetch(:whenever_environment)}&path=#{fetch(:current_path)}'" | ||
end | ||
end | ||
|
||
desc 'Update crontab' | ||
task update: :environment do | ||
comment "Update crontab for #{fetch(:whenever_name)}" | ||
in_path fetch(:current_path) do | ||
command "#{fetch(:bundle_bin)} exec whenever --update-crontab #{fetch(:whenever_name)} --set 'environment=#{fetch(:rails_env)}&path=#{fetch(:current_path)}'" | ||
command "#{fetch(:bundle_bin)} exec whenever --update-crontab #{fetch(:whenever_name)} --set 'environment_variable=#{fetch(:whenever_environment_variable)}&environment=#{fetch(:whenever_environment)}&path=#{fetch(:current_path)}'" | ||
end | ||
end | ||
|
||
desc 'Write crontab' | ||
task write: :environment do | ||
comment "Write crontab for #{fetch(:whenever_name)}" | ||
in_path fetch(:current_path) do | ||
command "#{fetch(:bundle_bin)} exec whenever --write-crontab #{fetch(:whenever_name)} --set 'environment=#{fetch(:rails_env)}&path=#{fetch(:current_path)}'" | ||
command "#{fetch(:bundle_bin)} exec whenever --write-crontab #{fetch(:whenever_name)} --set 'environment_variable=#{fetch(:whenever_environment_variable)}&environment=#{fetch(:whenever_environment)}&path=#{fetch(:current_path)}'" | ||
end | ||
end | ||
end |