简体   繁体   English

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

[英]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.jsapplication.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.

相关问题 Rails rake资产:用于生产的预编译 - Rails rake assets:precompile for production 生产中的 rails 6 webpacker:rake 资产:预编译失败 - rails 6 webpacker in production: rake assets:precompile fails 耙资产:预编译生产缓慢 - rake assets:precompile is slow in production 耙式资产:预编译无法在生产环境中使用 - rake assets:precompile not working on production Rails 5- RAILS_ENV =生产耙资产:预编译与耙资产:预编译之间的差异 - Rails 5- Difference between RAILS_ENV=production rake assets:precompile and rake assets:precompile rake assets:precompile 和 RAILS_ENV=production rake assets:precompile 有什么区别? - what's the differences between rake assets:precompile and RAILS_ENV=production rake assets:precompile? 运行rake资产后的数据表未在生产模式下显示:预编译。 导轨3.2 - Datatables not showing in production mode after running rake assets:precompile. rails 3.2 无法运行rake资产:在rails中预编译 - can't running rake assets:precompile in rails 运行时遇到错误cmd RAILS_ENV =生产包exec rake资产:预编译 - got error when run cmd RAILS_ENV=production bundle exec rake assets:precompile rake资产:预编译RAILS_ENV =生产不按要求工作 - rake assets:precompile RAILS_ENV=production not working as required
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM