ruby - Unicorn 在部署后定期无法重新启动 - PID 过时

标签 ruby chef-infra unicorn pid upstart

我已经尝试自己解决这个问题有一段时间了,但没有任何运气。当我重新部署 Rails 应用程序时,大约有 10% 的时间会出现这种情况。另外 90% 的时间部署进展顺利。

我试了又试,还是没有成功。所以我向广大群众寻求帮助。

关于我的堆栈的一些信息:我正在使用 Chef 在运行于 Ubuntu 14.04 上的 vagrant 上生成我的实例,并使用 upstart 来生成海外 unicorn 。

错误:

srv/www/rails/releases/ef6a792a19f8bb9d36ef4d0ab15ee38ca91a0cd1/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:206:in `pid=': Already running on PID:17694 (or pid=/srv/www/rails/shared/pids/unicorn.pid is stale) (ArgumentError)
from /srv/www/rails/releases/ef6a792a19f8bb9d36ef4d0ab15ee38ca91a0cd1/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:135:in `start'
from /srv/www/rails/releases/ef6a792a19f8bb9d36ef4d0ab15ee38ca91a0cd1/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
from /srv/www/rails/releases/ef6a792a19f8bb9d36ef4d0ab15ee38ca91a0cd1/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `load'
from /srv/www/rails/releases/ef6a792a19f8bb9d36ef4d0ab15ee38ca91a0cd1/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `<main>'

我的 unicorn Upstart 脚本是 here 。而我的 unicorn 配置文件​​可以查看here .

如果您需要更多信息,请告诉我。以上感谢您的帮助和时间。

最佳答案

我也遇到过这个问题。在尝试运行 Unicorn 之前,您需要清除 upstart 脚本中的旧 PID 文件。

rm /srv/www/rails/shared/pids/unicorn.pid

或者,看看 https://github.com/tablexi/capistrano3-unicorn了解确定服务器状态并适当启动/重新启动 Unicorn 的方法。

关于ruby - Unicorn 在部署后定期无法重新启动 - PID 过时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28417417/

相关文章:

ruby-on-rails - 当我进行捆绑安装时,我收到了 kgio gem 的 gem 安装错误

ruby-on-rails - -苏: bundle: command not found when starting unicorn

ruby-on-rails - Ruby on Rails 存储用户信息

amazon-web-services - 当我们不提及节点名称时,Chef 如何获取 aws ec2 的实例 ID

chef-infra - Vagrant Box 上的 Chef : Can't find encrypted data bag secret

chef-infra - 删除名称中包含换行符的客户端

ruby-on-rails - 如果我不在 after_fork 中 $redis = Redis.new 会发生什么?

ruby-on-rails - 在 Ruby 中通过递归嵌套哈希

ruby : How can I detect/intelligently guess the delimiter used in a CSV file?

sql - Rails ActiveRecord where 子句