Rails——我可以运行rake资产:在生产服务器上预编译,而生产应用程序还在运行吗?

时间:2022-11-10 20:37:28

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. 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.

我目前正在Ubuntu服务器上运行Rails应用程序。到目前为止,我总是在提取更改之前关闭产品应用程序,运行rake assets:clean assets:precompile,只在过程完成后重新启动Rails应用程序。

I'm not sure whether the shutting down of app is necessary(i.e. if I don't do it, my app will behave erratically). It induces about 5 minutes of down time.

我不确定是否需要关闭app(即。如果我不这么做,我的应用程序就会运行不正常)。大约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_流水线.html#local- precompile,然后删除原始公共/资产并从repo中提取本地预编译的公共/资产后,生产服务器一直处于挂起超时状态,不会呈现任何内容)。

1 个解决方案

#1


3  

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. 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. 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资产:预编译Rails查看您的资产文件夹,并将所有不是Javascript或CSS的文件复制到公共/资产中。然后创建应用程序。js通过阅读应用程序资产\ \ javascripts \应用程序。js和应用程序。通过阅读应用css \资产\ \应用样式表。css,加载它在那里找到的所有“需要”文件。是的. .你能做到的。但是如果你使用rake资产:clean.然后预编译…然后,公共/资产将使用新的已编译资产进行更新。

Dont forget to restart the server :)

不要忘记重新启动服务器:)

#1


3  

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. 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. 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资产:预编译Rails查看您的资产文件夹,并将所有不是Javascript或CSS的文件复制到公共/资产中。然后创建应用程序。js通过阅读应用程序资产\ \ javascripts \应用程序。js和应用程序。通过阅读应用css \资产\ \应用样式表。css,加载它在那里找到的所有“需要”文件。是的. .你能做到的。但是如果你使用rake资产:clean.然后预编译…然后,公共/资产将使用新的已编译资产进行更新。

Dont forget to restart the server :)

不要忘记重新启动服务器:)