abstract
- unicornが起動できない - エラーログを確認しようと思ったがunicorn.logが生成されていない - 別件だがNginxのログファイルも生成されていない(こちらはログファイルの記述自体を削除したのでエラーは吐かれていない)
こちらの記事を参考にrailsアプリをデプロイしようとしています。
https://qiita.com/naoki_mochizuki/items/5a1757d222806cbe0cd1
sudo service nginx start
コマンドでNginxを起動した後に下記の画面が表示されたので
Nginx起動後
bash
[username@ip]$ unicorn_rails -c /var/www/rails/rails_app/config/unicorn.conf.rb -D -E production Traceback (most recent call last): 11: from /home/username/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<main>' 10: from /home/username/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `load' 9: from /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.5.1/bin/unicorn_rails:209:in `<top (required)>' 8: from /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.5.1/bin/unicorn_rails:209:in `new' 7: from /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.5.1/lib/unicorn/http_server.rb:79:in `initialize' 6: from /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.5.1/lib/unicorn/http_server.rb:79:in `new' 5: from /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.5.1/lib/unicorn/configurator.rb:77:in `initialize' 4: from /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.5.1/lib/unicorn/configurator.rb:84:in `reload' 3: from /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.5.1/lib/unicorn/configurator.rb:84:in `instance_eval' 2: from /var/www/rails/rails_app/config/unicorn.conf.rb:10:in `reload' 1: from /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.5.1/lib/unicorn/configurator.rb:607:in `working_directory' /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.5.1/lib/unicorn/configurator.rb:607:in `chdir': No such file or directory @ dir_s_chdir - /var/www/rails/rails_app (Errno::ENOENT) master failed to start, check stderr log for details
unicornのエラーログを確認しようとしたところアプリケーション配下のlog
ディレクトリにunicorn.log
が存在していませんでした。
bash
[username@ip log]$ ls production.log [username@ip rails_app]$ less log/unicorn.stderr.log log/unicorn.stderr.log: No such file or directory
ログの確認方法 or ログファイルが生成されていない原因を教えていただけると幸いです。
プロセスの確認↓
[username@ip rails_app]$ ps -ef | grep unicorn username 30290 29889 0 06:36 pts/0 00:00:00 grep --color=auto unicorn [username@ip rails_app]$ ps -ef | grep unicorn | grep -v grep //出力なし
unicorn.conf.rb
unicorn.conf.rb
# set lets $worker = 2 $timeout = 30 $app_dir = "/var/www/rails/rails_app" # $listen = File.expand_path 'tmp/sockets/.unicorn.sock', $app_dir $pid = File.expand_path 'tmp/pids/unicorn.pid', $app_dir $std_log = File.expand_path 'log/unicorn.log', $app_dir # set config worker_processes $worker working_directory $app_dir stderr_path $std_log stdout_path $std_log timeout $timeout listen $listen pid $pid # loading booster preload_app true # before starting processes before_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! old_pid = "#{server.config[:pid]}.oldbin" if old_pid != server.pid begin Process.kill "QUIT", File.read(old_pid).to_i rescue Errno::ENOENT, Errno::ESRCH end end end # after finishing processes after_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end
まだ回答がついていません
会員登録して回答してみよう