我有一个unicorn.rb文件,我想根据环境变量设置worker_process。我试过没有成功以下方法:根据环境变化Unicorn 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/[email protected]/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/[email protected]/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:74:in `reload'
21:07:49 web.1 | from /home/hg/.rvm/gems/[email protected]/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:67:in `initialize'
21:07:49 web.1 | from /home/hg/.rvm/gems/[email protected]/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:104:in `new'
21:07:49 web.1 | from /home/hg/.rvm/gems/[email protected]/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:104:in `initialize'
21:07:49 web.1 | from /home/hg/.rvm/gems/[email protected]/gems/unicorn-4.3.1/bin/unicorn_rails:209:in `new'
21:07:49 web.1 | from /home/hg/.rvm/gems/[email protected]/gems/unicorn-4.3.1/bin/unicorn_rails:209:in `<top (required)>'
21:07:49 web.1 | from /home/hg/.rvm/gems/[email protected]/bin/unicorn_rails:19:in `load'
21:07:49 web.1 | from /home/hg/.rvm/gems/[email protected]/bin/unicorn_rails:19:in `<main>'
21:07:49 web.1 | from /home/hg/.rvm/gems/[email protected]/bin/ruby_noexec_wrapper:14:in `eval'
21:07:49 web.1 | from /home/hg/.rvm/gems/[email protected]/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
我能请得到的我怎么能解决这个指针?谢谢。
这是整个unicorn.rb文件吗?你可以将它完全粘贴,还是要求它或确认它确实满了?我看到它在抱怨:在我无法辨认的第4行。第一个建议是避免将环境作为一个变量,因为它可能在独角兽内部使用? –
这是我完整的[gist文件](https://gist.github.com/4633113)。奇怪的是,现在我再试一次,它正在工作。 – Hengjie
我怀疑你可能遗漏了一个:在那里是错误的。 :)使用vi/vim? –