ruby - Clockwork and register_javascript_expansion exception -


i'm using sidekiq , clockwork background jobs , scheduling. lib/clock.rb has next code executing rake task:

require 'clockwork' require file.expand_path('../../config/boot',        __file__) require file.expand_path('../../config/environment', __file__) require 'sidekiq'  include clockwork include sidekiq  module clockwork       every(1.day, 'rake places:get_from_api', at: '22:45')     sidekiq.logger.info 'starting rake places:get_from_api'     execute_rake('places.rake', 'places:get_from_api') if rails.env.production?   end end  def execute_rake(file,task)   require 'rake'   rake = rake::application.new   rake.application = rake   rake::task.define_task(:environment)   load "#{rails.root}/lib/tasks/#{file}"   rake[task].invoke end 

i deploy application on engineyard , have after_restart.rb hook:

if environment == 'production'   cw_pid_file = "#{shared_path}/pids/clockwork.pid"   # stop clockwork   run "if [ -d #{current_path} ] && [ -f #{cw_pid_file} ]; cd #{current_path} && kill -int $(cat #{cw_pid_file}) 2>/dev/null; else echo 'clockwork not running' ; fi"   ## start clockwork   run "cd #{current_path} && bundle exec clockworkd -c #{current_path}/lib/clock.rb --pid-dir #{shared_path}/pids --log --log-dir #{shared_path}/log restart >> log/clockwork.log 2>&1 &"   run "ps -eo pid,command | grep clockwork | grep -v grep | awk '{print $1}' > #{cw_pid_file}" end 

after deploying see an exception in clockworkd.clock.output log.

how fixed it?

engine yard staff here.

looking @ error, trying call each statement on nil somewhere. in custom rake task. can't debug without seeing more of code.

also can recommend plain cron tasks better way run regular tasks on engine yard instead of using clockwork.

  1. at bottom of environment click on crontabs (picture http://d.pr/i/3yeo )
  2. add job giving job name, command e.g. running rake task: cd /data/app_name/current && rails_env=production /usr/local/bin/bundle exec rake task_name
  3. give user , time interval , press create.
  4. back on environment press apply.

if more ruby method of setting cron tasks in rails, there nice gem called whenever allows write cron tasks in ruby written crontab. google whenever on engine yard returns posts on how other people have went doing doing simple showed, above instructions easiest.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -