Skip to content

Commit b8a2936

Browse files
committed
Add whenever support
1 parent db915ca commit b8a2936

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/tasks/eb_fast_deploy.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'aws-sdk'
33
require 'dotenv/environment'
44
require 'fog'
5+
require 'erb'
56

67
module EbFastDeploy
78

@@ -267,6 +268,28 @@ def print_env
267268

268269
end
269270

271+
desc "Set eb extension to run whenever on all instances"
272+
task :whenever_ebextension do
273+
set_vars
274+
if @eb_ruby_container_options["WHENEVER_ALL"] == "true"
275+
template=<<-EOF
276+
commands:
277+
01whenever:
278+
command: bundle exec whenever --set environment=$RACK_ENV -u webapp --update-crontab >/tmp/whenever_command.log 2>&1
279+
leader_only: false
280+
EOF
281+
output_file = ".ebextensions/whenever_all.config"
282+
dir = File.dirname output_file
283+
unless File.directory?(dir)
284+
FileUtils.mkdir_p(dir)
285+
end
286+
File.delete output_file if File.exists? output_file
287+
output = File.open(File.join(Rails.root, output_file), "w")
288+
output << ERB.new( template).result(binding)
289+
end
290+
end
291+
292+
270293
desc "print the current env status"
271294
task :print_current_status do
272295
set_vars
@@ -339,6 +362,7 @@ def print_env
339362
desc "deploy to elastic beanstalk"
340363
task :deploy => [
341364
:assets,
365+
:whenever_ebextension,
342366
:bundle_pack,
343367
:upload,
344368
:create_and_deploy_version

0 commit comments

Comments
 (0)