[英]Rails - Can I run rake assets:precompile on production server, while the production app is still running?
Sorry if this question sounds basic. 对不起,这个问题听起来很基本 But I haven't been able to find an answer anywhere on the web...
但我无法在网络上的任何地方找到答案......
I'm currently running my Rails app on a Ubuntu server. 我目前正在Ubuntu服务器上运行我的Rails应用程序。 Until now I've always shut down the production app before I pull the changes, run
rake assets:clean assets:precompile
, and only boot up the Rails app again once the process is finished. 到目前为止,我总是关闭生产应用程序,然后再进行更改,运行
rake assets:clean assets:precompile
,并且只在进程完成后再次启动Rails应用程序。
I'm not sure whether the shutting down of app is necessary(ie if I don't do it, my app will behave erratically). 我不确定是否需要关闭应用程序(即如果我不这样做,我的应用程序将表现不正常)。 It induces about 5 minutes of down time.
它会导致大约5分钟的停机时间。
If that's a must, then maybe I should try to do local precompilation/more advanced deployment procedure, in order to reduce downtime? 如果这是必须的,那么也许我应该尝试进行本地预编译/更高级的部署程序,以减少停机时间? (Tried local compilation according to http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation , but then after deleting original
public/assets
and pulling locally precompiled public/assets
from the repo, the production server was having rack timeout all the time and won't render anything.) (根据http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation尝试本地编译,但是在删除原始
public/assets
并从repo中提取本地预编译的public/assets
后,生产服务器正在进行机架超时所有的时间都不会呈现任何东西。)
YES you run rake assets:precompile
Rails looks through your assets
folder and copies over everything that is not Javascript or CSS into public/assets
. 是的,您运行
rake assets:precompile
Rails查看您的assets
文件夹,并将非Javascript或CSS的所有内容复制到public/assets
。 It then creates application.js
by reading app\\assets\\javascripts\\application.js
, and application.css
by reading app\\assets\\stylesheets\\application.css
, loading up all the "require" files it finds in there. 然后通过读取
app\\assets\\javascripts\\application.js
和application.css
来创建application.js
,通过读取app\\assets\\stylesheets\\application.css
,加载它在那里找到的所有“require”文件。 So yes..you can do it ..but if you ran rake assets:clean
..and then precompile...then public/assets
will be updated with new compiled assets. 所以是的 ..你可以这样做 .. 但如果你运行
rake assets:clean
..然后预编译......那么public/assets
将用新的编译资产更新。
Dont forget to restart the server :) 别忘了重启服务器 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.