LoginSignup
0
0

More than 3 years have passed since last update.

capistranoでのデプロイ時に、assets:precompile でメモリエラーが発生する

Last updated at Posted at 2019-05-23

エラー内容

capistranoでのデプロイ時に、デプロイ先サーバでassets:precompileをするのですが、これがメモリ不足で失敗しました。
以下はエラーログです。

log/capistrano.log
 INFO [12ac274e] Running $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile as hoge@fuga.piyo
DEBUG [12ac274e] Command: cd /var/www/hoge/releases/20190523032428 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.1" RAILS_ENV="staging" RAILS_GROUPS="" ; $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

対処法

1. サーバにSwap領域を追加する。

Ubuntu 16.04だったので、以下のサイトを参考にSwap領域を2GB追加しました。

参考: swap領域拡張手順(ファイル割当)

2. 環境変数 NODE_OPTIONS に max-old-space-size を設定する

デプロイ先のサーバにssh接続し、以下の環境変数を追加します。

$ sudo vim /etc/environment
# 以下の行を追加してください
export NODE_OPTIONS="--max-old-space-size=2048"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0