我将使用ruby脚本运行rake任务。
但我认为在运行纯ruby脚本之前,工头无法指定环境(我想用rbenv 2.2.2运行)
我确信eval "$(rbenv init -)" ; cd /home/user123/workspace/lazy-bird-website/ ; ruby notification_periodic_tasks.rb
可以在crontab中运行,但如何与领班执行相同的命令
worker: ruby notification_periodic_tasks.rb
我得到了这个例外
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- pry (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from notification_periodic_tasks.rb:1:in `<main>'
require 'pry'
require 'active_support/all'
require 'rufus-scheduler'
require 'awesome_print'
scheduler = Rufus::Scheduler.new
scheduler.every '30m' do
ap("start tasks")
system("RAILS_ENV=production bundle exec rake notification:add")
system("RAILS_ENV=production bundle exec rake notification:send")
end
scheduler.join
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
user123:x:1001:1001:,,,:/home/user123:/bin/zsh