前提・実現したいこと
EC2上からunicorn_rails -c config/unicorn.rb -E productionでrailsを立ち上げようとすると下記のようなエラーが出てしまいます。
発生している問題・エラーメッセージ
/home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/unicorn-5.4.0/lib/unicorn/configurator.rb:100:in `block in reload': directory for stderr_path=/var/www/protospace_in_dev/log/unicorn.stderr.log not writable (ArgumentError) from /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/unicorn-5.4.0/lib/unicorn/configurator.rb:96:in `each' from /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/unicorn-5.4.0/lib/unicorn/configurator.rb:96:in `reload' from /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/unicorn-5.4.0/lib/unicorn/configurator.rb:77:in `initialize' from /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:77:in `new' from /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:77:in `initialize' from /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/unicorn-5.4.0/bin/unicorn_rails:209:in `new' from /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/unicorn-5.4.0/bin/unicorn_rails:209:in `<top (required)>' from /home/ec2-user/.rbenv/versions/2.3.1/bin/unicorn_rails:23:in `load' from /home/ec2-user/.rbenv/versions/2.3.1/bin/unicorn_rails:23:in `<main>'
該当のソースコード
config/unicorn.rb
ruby
1app_path = File.expand_path('../../', __FILE__) 2 3worker_processes 1 4 5working_directory app_path 6pid "#{app_path}/tmp/pids/unicorn.pid" 7stderr_path "#{app_path}/log/unicorn.stderr.log" 8stdout_path "#{app_path}/log/unicorn.stdout.log" 9 10listen 3000 11timeout 60 12 13preload_app true 14GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true 15 16check_client_connection false 17 18run_once = true 19 20before_fork do |server, worker| 21 defined?(ActiveRecord::Base) && 22 ActiveRecord::Base.connection.disconnect! 23 24 if run_once 25 run_once = false # prevent from firing again 26 end 27 28 old_pid = "#{server.config[:pid]}.oldbin" 29 if File.exist?(old_pid) && server.pid != old_pid 30 begin 31 sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU 32 Process.kill(sig, File.read(old_pid).to_i) 33 rescue Errno::ENOENT, Errno::ESRCH => e 34 logger.error e 35 end 36 end 37end 38 39after_fork do |_server, _worker| 40 defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection 41end
試したこと
unicornのプロセスは起動していました。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。