擅长:python、mysql、java
<p>好吧,因为我没有足够的代表来评论,我在这里要提到的是,这个缺失的插座并没有暗示出太多的特殊性,但是我可以告诉你一些我是如何从你的角度出发,让事情顺利进行的。</p>
<p>长短不一的是,gunicorn在被新贵经营时遇到了一个问题,要么从未起来经营,要么就停产了。以下是一些步骤,可以帮助您获取更多信息以跟踪您的问题:</p>
<ul>
<li>在我的例子中,当发生这种情况时,gunicorn从来没有做过任何错误日志记录,所以我不得不寻找其他地方。试着<code>ps auxf | grep gunicorn</code>看看你有没有工人要去。我没有</li>
<li>在系统日志中查找来自upstart的投诉,<code>grep init: /var/log/syslog</code>,显示我的gunicorn服务已经停止,因为它重生太快了,尽管我怀疑这会是您的问题,因为您的配置中没有重生。无论如何,您可能会在那里找到一些东西。</li>
<li><p>在看到gunicorn无法运行或记录错误后,我决定尝试从命令行运行它。转到manage.py所在的目录,对gunicorn实例运行upstart命令的扩展版本。比如(用适当的垃圾代替我使用的垃圾)</p>
<p><code>/path/to/your/virtualenv/bin/gunicorn --name myapp --workers 4 --max-requests 10 --user appuser --group webusers --log-level debug --error-logfile /somewhere/I/can/find/error.log --bind unix:/tmp/myapp.socket myapp.wsgi</code></p></li>
<li><p>如果幸运的话,在手动运行该命令之后,您可能会得到一个python回溯,或者在gunicorn错误日志中找到一些内容。有些事情可能会出错:</p>
<ul>
<li>django错误(加载设置模块时可能出现问题?)。确保wsgi.py引用的是服务器上相应的设置模块。</li>
<li>新贵脚本中的空白问题。我有一个标签藏在那些把东西塞满的地方。</li>
<li>用户/权限问题。最后,我可以在命令行上以根用户的身份运行gunicorn,但不能通过upstart配置以非根用户的身份运行。</li>
</ul></li>
</ul>
<p>希望能有所帮助。追踪这些东西已经有好几天了。</p>