2011-04-01 90 views
3

我从cron运行我的rake任务时遇到问题,我把它包装在shell文件中,当我从控制台执行这个shell文件时它工作正常。Rails3,从cron运行rake任务

#!/bin/sh 

if ps -ef | grep -v grep | grep create_all_accounts ; then 
    exit 0 
else 
    cd /home/prosoftstudio/www/prosoftstudio_egabinet && /home/prosoftstudio/www/.ruby/gems/1.8/bin/rake gabinet:create_all_accounts RAILS_ENV=production --trace 
    exit 0 
fi 

项中的crontab看起来像这样(我设置PATH和GEM_PATH)

PATH=/home/prosoftstudio/www/.python/bin:/usr/local/python2.6/bin:/home/prosoftstudio/www/.ruby/gems/1.8/bin/:/usr/local/ruby1.8/bin:/usr/local/bin:/usr/bin:/bin:/us$ 
GEM_PATH=/home/prosoftstudio/www/.ruby/gems/1.8:/home/prosoftstudio/www/.ruby/gems/1.8/bundler/gems:/usr/lib/ruby/gems/1.8/ 
*/1 * * * * /home/prosoftstudio/www/cron_create_accounts.sh > cron_log.txt 2>&1 

我得到的输出是

rake aborted! 
git://github.com/100hz/rails-settings.git (at master) is not checked out. Please run `bundle install` 

现在看来似乎无法找到安装宝石

gem "rails-settings", :git => "git://github.com/100hz/rails-settings.git" 

任何人都知道如何解决这个问题?

回答

0

我想出了解决方法 - 从源头

wget https://github.com/100hz/rails-settings/zipball/master --no-check-certificate 
unzip 100hz-rails-settings-v0.1.1-0-g330b958.zip 
cd 100hz-rails-settings-330b958/ 
gem build rails-settings.gemspec 
gem install rails-settings-0.1.1.gem 

安装护栏的设置,你必须删除“:混帐=>”从宝石“轨道的设置”,在Gemfile中,然后运行

bundle install 

更新Gemfile.lock

之后,我的脚本从cron运行。

0

为了避免建设创业板,另一种选择是把宝石内容供应商文件夹,并引用它通过:路径的Gemfile:

gem "my_gem", :path => "vendor/my_gem"