2014-10-12 149 views
0

对于我在服务器上运行的脚本,我遇到了一个非常奇怪的问题,详情如下。但基本上我正在使用脚本来设置一个rails应用程序,并且我正在从现有的rails应用程序调用该脚本。使用系统命令运行RAILS_ENV = production

在我现有的应用程序(即调用服务器上的脚本应用程序),我有: -

Spawnling.new do 
    system "cd ~/ && ~/*/create_site.sh param1 param2 >> /tmp/logger" 
end 

的create_site.sh脚本使用下面的创建轨道的全新安装:

rails new $DIR --database postgresql 

然后,它做了许多事情来设置应用程序。问题是,剧本似乎直到它到达下面的命令来运行的精绝:

cd $DIR && RAILS_ENV=production rails g roroacms:install -v && RAILS_ENV=production rake assets:clean && RAILS_ENV=production rake assets:precompile 

这是非常奇怪,因为当我手动运行top命令以root用户似乎运行没有任何绝对精品问题。当我在顶部命令的末尾查看记录器文件,它看起来像下面:

Your bundle is updated! 
Bundle is installed and up to date 
RoroaCMS installation 
Installation complete with assets 
Server started 

当运行此手动它在那里它正在运行的命令输出数每行之间的消息。对此有何想法?我认为这可能与RAILS_ENV有关,因为rails new命令早期在脚本中正常运行。

+0

你是否以root身份运行脚本? – Travis 2014-10-12 18:35:36

+0

那么当我以root身份手动运行它时,它可以正常运行,但是当我在cron或上述命令中运行该命令时,它在导轨g roroacms上失败:安装我认为这可能与此有关,但没有错误消息,所以它真的很难调试 – 2014-10-13 10:51:49

回答

0

嗨,我在服务器上做了一些脚本导轨,我总是使用格式bundle exec rails g rspec:install production,所以你的命令是cd $DIR && bundle exec rails g roroacms:install -v production && bundle exec rake assets:clean production && bundle exec rake assets:precompile production。我没有很多推理,但是这种格式在不同的服务器环境下似乎是最可靠的。