独角兽挂着“清爽宝石”的字样
从乘客迁移到独角兽后,我在分期中遇到了一个奇怪的问题。
我为开发和登台环境配置了 unicorn。 它在开发中起作用,但在分期中不起作用。在开发过程中,它监听 8080,而在暂存阶段,它监听 unix 套接字。这会有什么不同吗?特别是在生产环境中?
这就是我在暂存中运行它时发生的情况,
- 启动时几乎占用 100% CPU,
- 有时它会稳定下来,我可以使用它
- *但大多数时候它会挂起**,我不得不杀死它。
我已记录了有关此问题的问题单击此处
这是我在 unicorn.stderr.log 中看到的内容,
I, [2011-08-26T09:02:53.324286 #5026] INFO -- : unlinking existing socket=/home/krishnaprasad/project_name/tmp/sockets/unicorn.sock
I, [2011-08-26T09:02:53.324502 #5026] INFO -- : listening on addr=/home/krishnaprasad/project_name/tmp/sockets/unicorn.sock fd=3
I, [2011-08-26T09:02:53.324860 #5026] INFO -- : Refreshing Gem list
为什么它会尝试刷新 gem? 有什么办法可以在配置文件中避免它吗?
这就是我在 config/unicorn_staging.rb 中的内容,
# unicorn_rails -c /config/unicorn_staging.rb -E staging -D
rails_env = 'staging'
working_directory "/home/krishnaprasad/Projects/project_name"
worker_processes 1
preload_app true
timeout 90
rails_root = "/home/krishnaprasad/Projects/project_name"
listen "#{rails_root}/tmp/sockets/unicorn.sock", :backlog => 2048
pid "#{rails_root}/tmp/pids/unicorn.pid"
stderr_path "#{rails_root}/log/unicorn.log"
stdout_path "#{rails_root}/log/unicorn.log"
GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
before_fork do |server, worker|
ActiveRecord::Base.connection.disconnect!
old_pid = "#{Rails.root}/tmp/pids/unicorn.pid.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end
after_fork do |server, worker|
ActiveRecord::Base.establish_connection
end
非常感谢任何帮助。 提前致谢
I have a strange problem in staging after i migrated to unicorn from passenger.
I configured unicorn for both development and staging environment .
its working in development but not in staging. In development its listening to 8080 where as in staging its listening to a unix socket. Will that make any diferrence ? Especially in production kinda env?
This is what happens when i run it in staging
- It takes almost 100% CPU while starting
- sometimes it settles down and i am able to use it
- *But most of the times it hangs** and i had to kill it.
I have logged a question regarding this issue click here
This is what i see in unicorn.stderr.log
I, [2011-08-26T09:02:53.324286 #5026] INFO -- : unlinking existing socket=/home/krishnaprasad/project_name/tmp/sockets/unicorn.sock
I, [2011-08-26T09:02:53.324502 #5026] INFO -- : listening on addr=/home/krishnaprasad/project_name/tmp/sockets/unicorn.sock fd=3
I, [2011-08-26T09:02:53.324860 #5026] INFO -- : Refreshing Gem list
why does it try to refresh the gems ?
is there any way to avoid it in config file ?
this is what i have in config/unicorn_staging.rb
# unicorn_rails -c /config/unicorn_staging.rb -E staging -D
rails_env = 'staging'
working_directory "/home/krishnaprasad/Projects/project_name"
worker_processes 1
preload_app true
timeout 90
rails_root = "/home/krishnaprasad/Projects/project_name"
listen "#{rails_root}/tmp/sockets/unicorn.sock", :backlog => 2048
pid "#{rails_root}/tmp/pids/unicorn.pid"
stderr_path "#{rails_root}/log/unicorn.log"
stdout_path "#{rails_root}/log/unicorn.log"
GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
before_fork do |server, worker|
ActiveRecord::Base.connection.disconnect!
old_pid = "#{Rails.root}/tmp/pids/unicorn.pid.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end
after_fork do |server, worker|
ActiveRecord::Base.establish_connection
end
Any help highly appreciated.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保您的代码没有语法错误!
对我来说,修复语法错误(在我的一个控制器中)结束了循环并正确启动了 Unicorn。我在 Unicorn 中没有收到任何错误消息,您可能想尝试开始使用 WebRat 并查看是否弹出错误。
Make sure your code is free of syntax errors!
For me fixing a syntax error (in one of my controllers) ended the loop and started Unicorn properly. I did not get any error messages in Unicorn, you might want to try to start using WebRat and see if an error pops up.
对我来说,这是数据库连接配置不正确。似乎有时它在控制台上报告这一点,有时它只是旋转。
For me, it was the database connection wasn't configured correctly. It seems like sometimes it reports this at the console, sometimes it just spins.