简体   繁体   中英

how to execute rake tasks using whenever gem, in amazon aws server in ruby on rails?

iam using whenever gem to execute a rake task, in my rails application. in development environment everything is working fine this is the following code.

 set :environment, "development"
 set :output, {:error => "log/cron_error_log.log", :standard => "log/cron_log.log"}

 every :day, :at => '12:10pm' do
  runner "Employee.assign_shift_policies"
 end 

and in terminal to create a crontab and to run that cron tab file by using whenever gem iam running the following commands.

 whenever
 whenever -w 

and the tasks are executing correctly. and the output of these rake tasks is appending to the following log files properly.

 log/cron_error_log.log
 log/cron_log.log

in development everthing is working fine. how to run these background jobs in amazon aws beanstalk server, means how to execute these whenever and whenever -w commands in amazon aws server to generate crontab and to execute those jobs in aws server by using elastic beanstalk?

now, i am using whenever-elasticbeanstalk gem. i am getting the following error in eb-activity.log file.

Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError)
caused by: /var/app/ondeck/vendor/bundle/gems/whenever-elasticbeanstalk-1.1.6/bin/create_cron_leader:10:in `join': no implicit conversion of nil into String (TypeError)
  from /var/app/ondeck/vendor/bundle/gems/whenever-elasticbeanstalk-1.1.6/bin/create_cron_leader:10:in `<top (required)>'
  from /var/app/ondeck/vendor/bundle/bin/create_cron_leader:23:in `load'
  from /var/app/ondeck/vendor/bundle/bin/create_cron_leader:23:in `<main>'
   (ElasticBeanstalk::ExternalInvocationError)

You have a gem that doing exactly what you need:

https://github.com/dignoe/whenever-elasticbeanstalk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM