我已经尝试自己解决这个问题有一段时间了,但没有任何运气。当我重新部署 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/