unicorn.rb ファイルがあり、環境変数に応じて worker_process を設定したいと考えています。私は成功せずに次のアプローチを試みました:
environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production'
# Save on RAM while in development
if environment == 'development'
worker_processes 1
else
worker_processes 4
end
使用するforeman start
と、次のエラーが発生します。
21:07:49 web.1 | /home/hg/.rvm/gems/ruby-1.9.3-p194@px/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:74:in `instance_eval': ./unicorn.rb:4: syntax error, unexpected ':', expecting keyword_then or ';' or '\n' (SyntaxError)
21:07:49 web.1 | ./unicorn.rb:6: syntax error, unexpected keyword_else, expecting $end
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:74:in `reload'
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:67:in `initialize'
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:104:in `new'
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:104:in `initialize'
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/gems/unicorn-4.3.1/bin/unicorn_rails:209:in `new'
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/gems/unicorn-4.3.1/bin/unicorn_rails:209:in `<top (required)>'
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/bin/unicorn_rails:19:in `load'
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/bin/unicorn_rails:19:in `<main>'
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/bin/ruby_noexec_wrapper:14:in `eval'
21:07:49 web.1 | from /home/hg/.rvm/gems/ruby-1.9.3-p194@px/bin/ruby_noexec_wrapper:14:in `<main>'
21:07:49 web.1 | exited with code 1
21:07:49 system | sending SIGTERM to all processes
SIGTERM received
これを解決する方法を教えてください。ありがとう。