我有一个 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
我能否请教一下如何解决这个问题?谢谢。