作者:dengyuanc_928 | 来源:互联网 | 2023-06-11 12:53
IsetuparailsprojecttousetheWhenevergem.NowIdeploymyprojectwithCapistranoandtheta
I set up a rails project to use the Whenever gem. Now I deploy my project with Capistrano and the tasks are nicely added to crontab list. But when I see only one line:
我建立了一个rails项目来使用这个gem。现在我用Capistrano部署我的项目,这些任务很好地添加到crontab列表中。但当我只看到一行:
/bin/bash: bundle: command not found
So I read a couple of articles online so I added this on top of my schedule.rb file
我在网上读了几篇文章,所以我把它加在了我的课程表上。rb文件
env 'PATH', ENV['PATH']
So you should think problem solved, because this will add this next line to the crontab:
所以你应该认为问题已经解决了,因为这将为crontab添加下一行:
PATH=/var/rails/alfa_paints/shared/bundle/ruby/1.9.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
So you should think bundle is in the path when the command gets executed. But still no luck. I ran the command and the deployment with a seperate user. So to make sure everything runs with that user, deployer in this case. I asssumed the role of deployer and ran the command as specified in crontab. I didn't experience any problems when executing this command.
因此,当命令执行时,您应该认为bundle位于路径中。但是仍然没有运气。我使用一个独立的用户运行命令和部署。为了确保所有东西都能运行,在这个例子中是部署者。我分析了部署人员的角色,并按照crontab中指定的方式运行命令。执行此命令时,我没有遇到任何问题。
I'm running out of options and was wondering if anybody else experienced this strange behavior? I'm hoping for some advise. This is the output in my crontab:
我已经没有选择的余地了,我想知道是否还有其他人经历过这种奇怪的行为?我希望得到一些建议。这是我的crontab的输出:
# Begin Whenever generated tasks for: alfa_paints
PATH=/var/rails/alfa_paints/shared/bundle/ruby/1.9.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
0 1 * * * /bin/bash -l -c 'cd /var/rails/alfa_paints/releases/20130127192223 && RAILS_ENV=production bundle exec rake alfa:cleanup --silent >> /var/rails/alfa_paints/shared/log/whenever.log 2>&1'
# End Whenever generated tasks for: alfa_paints
Any help welkom!
任何帮助welkom !
2 个解决方案