Im trying to setup whenever gem in my Ubuntu 14.04 server. In my local machine it works fine. I use capistrano to deploy the site. I use rbenv in the server. But when installing passenger it installs Ruby 1.9 which I do not use. Only use rbenv. Here's my shcedule.rb :
set :output, "#{path}/log/cron.log"
every 30.minutes do
runner 'UploadmailWorker.perform_async'
end
every 12.hours do
runner 'SubscriptionWorker.perform_async'
end
every :month do
runner 'PaysellerWorker.perform_async'
end
My deploy.rb :
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}
set :whenever_roles, ->{ :app }
set :whenever_command, ->{ [:bundle, :exec, :whenever] }
set :whenever_command_environment_variables, ->{ {} }
set :whenever_identifier, ->{ fetch :application }
set :whenever_environment, ->{ fetch :rails_env, fetch(:stage, "production") }
set :whenever_variables, ->{ "environment=#{fetch :whenever_environment}" }
set :whenever_update_flags, ->{ "--update-crontab #{fetch :whenever_identifier} --set #{fetch :whenever_variables}" }
set :whenever_clear_flags, ->{ "--clear-crontab #{fetch :whenever_identifier}" }
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
end
After deploying, the whenever does not work. In the cron.log I find this error :
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/deploy/istockseller/releases/20150519112817/config/boot.rb:3:in `<top (required)>'
from bin/rails:7:in `require_relative'
from bin/rails:7:in `<main>'
How can I fix that?
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
Don't be confused, by this line. This is ruby library that get to be install for every ubuntu instances, so you can execute ruby commands.
You need cd to you project and install bundler.
Run this.
Update info for rbenv
Use ~/.bashrc on Ubuntu, or ~/.zshrc for Zsh