デプロイを行う際に発生したエラーで行なったことをメモ。
同じように困った方の参考になればと。
環境
ruby 2.3.1
Rails 5.0.7.2
MySQL
git
unicorn
nginx
capistrano
AWS EC2
発生したエラー
bundle exec cap production deploy
上記コマンド実行後、下記のようなエラーが発生する
00:08 deploy:assets:precompile
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 rake aborted!
01 ArgumentError: Missing required arguments: aws_access_key_id,
環境変数が読み込まれていない?
環境変数を念の為確認したが、特に異常なし。。
試したこと
[ec2-user@ip-XXX-XX-XX-XXX chat-space]$ kill -QUIT `cat tmp/pids/unicorn.pid`
cat: tmp/pids/unicorn.pid: そのようなファイルやディレクトリはありません
kill: 使用法: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... または kill -l [sigspec]
[ec2-user@ip-XXX-XX-XX-XXX chat-space]$ ps auxwww | grep unicorn
ec2-user 7949 0.0 10.2 365852 103808 ? Sl 00:07 0:02 unicorn master -c /var/www/chat-space/current/config/unicorn.rb -E deployment -D
ec2-user 8027 0.0 11.1 376292 112920 ? Sl 00:07 0:21 unicorn worker[0] -c /var/www/chat-space/current/config/unicorn.rb -E deployment -D
ec2-user 23353 0.0 0.2 110532 2132 pts/1 S+ 11:50 0:00 grep --color=auto unicorn
[ec2-user@ip-XXX-XX-XX-XXX chat-space]$ kill 7949
[ec2-user@ip-XXX-XX-XX-XXX chat-space]$ ps auxwww | grep unicorn
ec2-user 23355 0.0 0.2 110532 2172 pts/1 S+ 11:50 0:00 grep --color=auto unicorn
[ec2-user@ip-XXX-XX-XX-XXX chat-space]$ cd
[ec2-user@ip-XXX-XX-XX-XXX ~]$ sudo service nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
[ec2-user@ip-XXX-XX-XX-XXX ~]$ sudo service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
結論からいうと上記で改善しました。
kill -QUIT `cat tmp/pids/unicorn.pid`
cat: tmp/pids/unicorn.pid: そのようなファイルやディレクトリはありません
上記コマンドで「そのようなファイルやディレクトリはありません」となっていたので、
unicornは停止しているという認識だったのですが、
[ec2-user@ip-XXX-XX-XX-XXX chat-space]$ ps auxwww | grep unicorn
ec2-user 7949 0.0 10.2 365852 103808 ? Sl 00:07 0:02 unicorn master -c /var/www/chat-space/current/config/unicorn.rb -E deployment -D
ec2-user 8027 0.0 11.1 376292 112920 ? Sl 00:07 0:21 unicorn worker[0] -c /var/www/chat-space/current/config/unicorn.rb -E deployment -D
ec2-user 23353 0.0 0.2 110532 2132 pts/1 S+ 11:50 0:00 grep --color=auto unicorn
[ec2-user@ip-XXX-XX-XX-XXX chat-space]$ kill 7949
psコマンドで確認すると、処理があったのでKillコマンドで終了させています。
確認したところこういったことはあるそうです。
その後、nginxとMySQLの再起動を行なっています。
もし上記で改善しない場合、git pullとbundle installもその前に行なっていたので、
それも試してみるといいかもしれません。
何か参考になればと思います。
宜しくお願いします。