お世話になっております。
下記の問題について知見がある方がいらっしゃいましたらご教示お願いします。
起きている問題
$ bundle exec unicorn_rails -c /var/www/rails/coffee_app/config/unicorn.conf.rb -D -E production
bundler: failed to load command: unicorn_rails (/home/ryouya/.rbenv/versions/2.5.1/bin/unicorn_rails)
SyntaxError: /var/www/rails/coffee_app/config/unicorn.conf.rb:29: syntax error, unexpected keyword_end, expecting end-of-input
end
^~~
/home/ryouya/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-
:
(省略)
:
/home/ryouya/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<top (required)>'
master failed to start, check stderr log for details
AWS上のUnicornが起動しません。
SyntaxError: /var/www/rails/coffee_app/config/unicorn.conf.rb:29: syntax error, unexpected keyword_end, expecting end-of-input
エラー文としてはunicorn.conf.rb
でend
が多いという指摘をもらっているのですが、
end
の数は合っている認識です。
$worker = 2
$timeout = 30
$app_dir = "/var/www/rails/coffee_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_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end
試したこと
endを1つ無くす
別のエラーが発生しました。
$ bundle exec unicorn_rails -c /var/www/rails/coffee_app/config/unicorn.conf.rb -D -E production
bundler: failed to load command: unicorn_rails (/home/ryouya/.rbenv/versions/2.5.1/bin/unicorn_rails)
NameError: undefined local variable or method `old_pid' for #<Unicorn::Configurator:0x000000000164f540>
/var/www/rails/coffee_app/config/unicorn.conf.rb:23:in `reload'
:
(省略)
:
/home/ryouya/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<top (required)>'
master failed to start, check stderr log for details
EC2を再起動
問題解決にはなりませんでした。
関連ファイル
unicorn.conf.rb$worker = 2
$timeout = 30
$app_dir = "/var/www/rails/coffee_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_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end
環境
ruby 2.5.1
rails 5.1.6