部署 [求助] Capistrano Rails 6.0 ,yarn install 到 [4/4] Building fresh packages... 这一步总是很慢

tesla_lee · December 27, 2019 · Last by yuanchang replied at May 21, 2021 · 8961 hits

奔溃了,每次都是在这个地方执行很久,取消几次重新发布后,可能又正常额,就在刚才,等了一个小时也没有继续往下执行,下面是相关的日志。

** Execute deploy:updated
** Invoke deploy:compile_assets (first_time)
** Invoke deploy:set_rails_env
** Execute deploy:compile_assets
** Invoke deploy:assets:precompile (first_time)
** Execute deploy:assets:precompile
00:13 deploy:assets:precompile
      01 RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.6.5 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
      01 yarn install v1.9.4
      01 [1/4] Resolving packages...
      01 [2/4] Fetching packages...
      01 (node:2881) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from()
      01 info fsevents@1.2.9: The platform "linux" is incompatible with this module.
      01 info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
      01 [3/4] Linking dependencies...
      01 warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0".
      01 warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0".
      01 [4/4] Building fresh packages...
      01 Done in 170.88s.
      01 yarn install v1.9.4
      01 [1/4] Resolving packages...
      01 [2/4] Fetching packages...
      01 (node:2965) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from()
      01 info fsevents@1.2.9: The platform "linux" is incompatible with this module.
      01 info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
      01 [3/4] Linking dependencies...
      01 warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0".
      01 warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0".
      01 [4/4] Building fresh packages...

会不会内存不够用了……

应该是服务器上面 yarn 使用的镜像地址问题试试: yarn config set registry https://registry.npm.taobao.org yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g

建议前端自己在本地打包然后再上传到服务器,可以加快速度,节省资源

Reply to summer_wind

看日志已经过了 fetch 这步,到了 building。

Reply to Rei

而且好像发现 yarn install 执行了两次。

Reply to Rei

这么一说,我去查查看,实在不行我就考虑本地编译在发布了。

Reply to summer_wind

yarn 的镜像地址我已经修改了,前三步都很快,就是到 [4/4] fresh packages 这一步就会卡住了,时间特别长。

@Rei 大佬 借楼请教一下~(新人期没过不能发帖。。囧)ruby 怎样可以调用 so 库哦?我试过这种方式但是失败了

bash# cp rubytest.so /opt/test

bash# export RUBYLIB=$RUBYLIB:/opt/test

bash# irb

irb> require 'rubytest'

=> true

内存和 cpu 都有可能不够用。

我有一模一样的问题。 yarn 编译很慢,而且 yarn 跑两次。 一直忍受着。

之前有遇到过,可以尝试把 node_modules 目录设置成 linked_dirs。

可以 cache 不到位,比如 node_modules

我也遇到过,mina 部署,到这一步卡着不动。

遇到就手动杀掉,重新部署。每次执行时间不同且差别很大,几十秒 build 好到几十分钟没好,各种情况都遇到过,cpu 和内存没看出什么问题。

一样,每次 cap production deploy 就这个地方耗时最长

You need to Sign in before reply, if you don't have an account, please Sign up first.