独角兽挂着“清爽宝石”的字样

发布于 2024-12-01 17:05:43 字数 1908 浏览 1 评论 0原文

从乘客迁移到独角兽后,我在分期中遇到了一个奇怪的问题。

我为开发和登台环境配置了 unicorn。 它在开发中起作用,但在分期中不起作用。在开发过程中,它监听 8080,而在暂存阶段,它监听 unix 套接字。这会有什么不同吗?特别是在生产环境中?

这就是我在暂存中运行它时发生的情况,

  1. 启动时几乎占用 100% CPU,
  2. 有时它会稳定下来,我可以使用它
  3. *但大多数时候它会挂起**,我不得不杀死它。

我已记录了有关此问题的问题单击此处

这是我在 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

  1. It takes almost 100% CPU while starting
  2. sometimes it settles down and i am able to use it
  3. *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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傾城如夢未必闌珊 2024-12-08 17:05:43

确保您的代码没有语法错误!

对我来说,修复语法错误(在我的一个控制器中)结束了循环并正确启动了 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.

丶视觉 2024-12-08 17:05:43

对我来说,这是数据库连接配置不正确。似乎有时它在控制台上报告这一点,有时它只是旋转。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文