Skip to content

Commit 78af0a4

Browse files
committed
add environment_variable support
Fix mina-deploy#13 Signed-off-by: Laurent Vallar <[email protected]>
1 parent aedfccc commit 78af0a4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ These are the settings you can set:
3939

4040
set :whenever_name # default: "#{domain}_#{rails_env}"
4141

42+
# See https://github.com/javan/whenever#define-your-own-job-types for environment variable configuration
43+
set :whenever_environment_variable # default: fetch(:environment_variable) || 'RAILS_ENV'
44+
set :whenever_environment # default: fetch(fetch(:whenever_environment_variable).downcase.to_sym)
45+
4246
## Contributing
4347

4448
Bug reports and pull requests are welcome on GitHub at https://github.com/mina-deploy/mina-whenever. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

lib/mina/whenever/tasks.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
set :whenever_name, -> { "#{fetch(:domain)}_#{fetch(:rails_env)}" }
1+
set :whenever_environment_variable, -> { fetch(:environment_variable) || 'RAILS_ENV' }
2+
set :whenever_environment, -> { fetch(fetch(:environment_variable).downcase.to_sym) }
3+
set :whenever_name, -> { "#{fetch(:domain)}_#{fetch(:whenever_environment)}" }
24

35
namespace :whenever do
46
desc 'Clear crontab'
57
task clear: :environment do
68
comment "Clear contrab for #{fetch(:whenever_name)}"
79
in_path fetch(:current_path) do
8-
command "#{fetch(:bundle_bin)} exec whenever --clear-crontab #{fetch(:whenever_name)} --set 'environment=#{fetch(:rails_env)}&path=#{fetch(:current_path)}'"
10+
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)}'"
911
end
1012
end
1113

1214
desc 'Update crontab'
1315
task update: :environment do
1416
comment "Update crontab for #{fetch(:whenever_name)}"
1517
in_path fetch(:current_path) do
16-
command "#{fetch(:bundle_bin)} exec whenever --update-crontab #{fetch(:whenever_name)} --set 'environment=#{fetch(:rails_env)}&path=#{fetch(:current_path)}'"
18+
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)}'"
1719
end
1820
end
1921

2022
desc 'Write crontab'
2123
task write: :environment do
2224
comment "Write crontab for #{fetch(:whenever_name)}"
2325
in_path fetch(:current_path) do
24-
command "#{fetch(:bundle_bin)} exec whenever --write-crontab #{fetch(:whenever_name)} --set 'environment=#{fetch(:rails_env)}&path=#{fetch(:current_path)}'"
26+
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)}'"
2527
end
2628
end
2729
end

0 commit comments

Comments
 (0)