Q&A
初心者のものです。
現在、ruby on railsで開発したプログラムをデプロイしようとしているのですが、
その際に用いていたunicorn.rbが起動しません。
実行環境:centos7 unicorn (5.2.0) rails (4.2.7) ruby(2.2.5)
##実行コマンド
実行コマンド $ bundle exec unicorn -D -c unicorn.rb
最初は
ArgumentError: rackup file (config.ru) not readable
と言われたのでぐぐってみると、working_directoryを指定しないと
rackを読み込んでしまうとの記述をみつけました。
それに従い、以下のように実行ファイルを編集しました。
##ソースコード
パス
/var/www/app/my-app/current/config/unicorn.rb
ruby
1# -*- coding: utf-8 -*- 2worker_processes 2 3 4listen '/var/www/app/my-app/current/tmp/unicorn.sock' 5pid '/var/www/app/my-app/current/tmp/unicorn.pid' 6 7log = Dir.pwd + '/log/unicorn.log' 8stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT']) 9stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT']) 10 11#修正箇所 12working_directory '/var/www/app/current' 13 14preload_app true 15GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true 16 17before_fork do |server, worker| 18defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! 19 20old_pid = "#{ server.config[:pid] }.oldbin" 21unless old_pid == server.pid 22 begin 23 sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU 24 Process.kill :QUIT, File.read(old_pid).to_i 25 rescue Errno::ENOENT, Errno::ESRCH 26 end 27end 28end 29 30after_fork do |server, worker| 31 defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection 32end 33~
実行したところ、
ArgumentError: config_file=./unicorn.rb would not be accessible in working_directory=/var/www/app/current
と言われ、エラーとなります。
working_directoryの記述がおかしいのでしょうか。
お手数ですがどなたご教授いただきたくお願い致します。
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2016/12/16 16:20 編集
2016/12/19 07:41
2016/12/21 07:46
2016/12/21 08:04
2016/12/21 08:26