javan/whenever

Missing "script/runner", undocumented dependency on rails?

XanderStrike opened this issue · 2 comments

When I try to use this gem in a plain old ruby project, runner tasks fail with:

bundler: command not found: script/runner
Install missing gem executables with `bundle install`

I know this is exists in rails projects, but the readme didn't make it seem like Rails was a hard requirement. I'm just trying to run a script on a schedule and this gem seemed perfect.

schedule.rb:

set :output, "./checker.log"
every 1.minutes do
  runner "Checker.run"
end

I installed whenever using the instructions, added to my Gemfile and ran bundle exec wheneverize ., then whenever --update-crontab

try to use bundler: bundle exec whenever --update-crontab

s-s commented

try to use bundler: bundle exec whenever --update-crontab

Won't help. Experienced the very same issue in a plain ruby project. Whenever expects rails script to be present for runner tasks, otherwise it relies on the presence of script/runner:

set :runner_command, case
when Whenever.bin_rails?
"bin/rails runner"
when Whenever.script_rails?
"script/rails runner"
else
"script/runner"
end

Unfortunately, this script is missing and Whenever doesn't provide any option to create it. Having generator for such script or instructions in README or Wiki would be great.

I've solved this issue for myself by switching to rake tasks as my scenario allows them.

Another possible solution is to setup runner manually in config/schedule.rb, for example:

set :runner_command, 'ruby -r ./some/lib/dependency -e'
job_type :runner, 'cd :path && :bundle_command :runner_command ":task" :output'