前提・実現したいこと
現在、チーム開発で完成したWEBアプリをチーム各個人毎のEC2サーバーで立ち上げる作業をしております。
EC2サーバーにデプロイを行ったあと、ユニコーンを立ち上げる際に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails) ArgumentError: config_file=config/unicorn.rb would not be accessible in working_directory=/var/www/current /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:592:in `working_directory' config/unicorn.rb:5:in `reload' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `instance_eval' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `new' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<top (required)>' master failed to start, check stderr log for details
該当のソースコード
config/unicorn.rb
#サーバ上でのアプリケーションコードが設置されているディレクトリを変数に入れておく # ../が一つ増えている app_path = File.expand_path('../../../', __FILE__) #アプリケーションサーバの性能を決定する worker_processes 1 #アプリケーションの設置されているディレクトリを指定 # currentを指定 working_directory "#{app_path}/current" # それぞれ、sharedの中を参照するよう変更 #Unicornの起動に必要なファイルの設置場所を指定 pid "#{app_path}/shared/tmp/pids/unicorn.pid" #ポート番号を指定 listen "#{app_path}/shared/tmp/sockets/unicorn.sock" #エラーのログを記録するファイルを指定 stderr_path "#{app_path}/shared/log/unicorn.stderr.log" #通常のログを記録するファイルを指定 stdout_path "#{app_path}/shared/log/unicorn.stdout.log" ~~~後略
shared/log/unicorn.stderr.log
I, [2019-12-16T18:08:05.907242 #4722] INFO -- : Refreshing Gem list I, [2019-12-16T18:08:08.276922 #4722] INFO -- : listening on addr=/var/www/myAPP/shared/tmp/sockets/unicorn.sock fd=8 I, [2019-12-16T18:08:08.282860 #4722] INFO -- : master process ready I, [2019-12-16T18:08:08.291125 #4726] INFO -- : worker=0 ready I, [2019-12-16T18:08:08.515852 #4756] INFO -- : executing ["/var/www/myapp/shared/bundle/ruby/2.5.0/bin/unicorn", "-c", "/var/www/myapp/current/config/unicorn.rb", "-E", "production", "-D", {8=>#<Kgio::UNIXServer:/var/www/myapp/shared/tmp/sockets/unicorn.sock>}] (in /var/www/myapp/releases/20191216180611) I, [2019-12-16T18:08:08.515952 #4756] INFO -- : forked child re-executing... I, [2019-12-16T18:08:08.832267 #4756] INFO -- : inherited addr=/var/www/myapp/shared/tmp/sockets/unicorn.sock fd=8 I, [2019-12-16T18:08:08.832490 #4756] INFO -- : Refreshing Gem list I, [2019-12-16T18:08:11.125396 #4756] INFO -- : master process ready I, [2019-12-16T18:08:11.129116 #4798] INFO -- : worker=0 ready I, [2019-12-16T18:08:11.218315 #4722] INFO -- : reaped #<Process::Status: pid 4726 exit 0> worker=0 I, [2019-12-16T18:08:11.218411 #4722] INFO -- : master complete I, [2019-12-16T18:08:49.460777 #4756] INFO -- : reaped #<Process::Status: pid 4798 exit 0> worker=0 I, [2019-12-16T18:08:49.460900 #4756] INFO -- : master complete
試したこと
lsコマンドでcurrentフォルダの存在を確認しました。
補足情報(FW/ツールのバージョンなど)
ruby 2.5.1
Rails 5.2.3
unicorn 5.4.1
1)deployの手段は何を使っていますか
データの構造が分からないので
2) app_path 直下のfile、dirを教えてください
3) app_path/current 直下のfile,dirを教えてください。
4) unicorn.rb のfull path(/からのpath)を教えてください
情報が不足しており申し訳ございません。
1. deployにはCapistranoを使用しております。
2. app_path直下のfile,dirは
Capfile Gemfile.lock Rakefile bin
config.ru db log public repo
server.crt server.key spec test vendor
Gemfile README.md app
config current lib
package.json releases revisions.log server.csr
shared storage tmp
となっております。
3.app_path/current直下のfile,dirは
Capfile Gemfile.lock REVISION app
bin config.ru lib package.json spec
test vendor Gemfile README.md
Rakefile assets_manifest_backup
config db log public storage tmp
以上になっております。
4.unicornのfull_pathは
current/config/unicorn.rbです。
4 は相対pathです。/ からのfullpathでください。
あと追加ですが、app_path の定義も念の為ください
2,3の中身が一緒なのがおかしいのですが。
Capistrano をつかった場合私の経験では app_dirの下に
current releases 及び設定によっては shared があり、
currentは実際は releasesの下のdirへのsynbolic linkなのですが。
app_pathの直下のは何かの間違いでできたとして、上の質問への答えで様子が判るかと思います
4の回答なのですが /var/www/myapp/current/config/unicorn.rbでした。
申し訳ございません。
app_pathの定義はapp_path = File.expand_path('../../../', __FILE__)です。
自動デプロイ後、currentフォルダのunicorn.rbを参照すると理解していたため
上記の記述にしました。
app_pathの定義は /var/www/myapp/current/config/unicorn.rb に書かれているのですね?
はい。
そういった意図で記述しております。
情報が不足しており、申し訳ございません。。。
回答に書きます
回答1件
あなたの回答
tips
プレビュー