【问题标题】:Pserve won't stopPserve不会停止
【发布时间】:2013-11-29 10:42:42
【问题描述】:

我对金字塔和 pserve 还很陌生,但我遇到了一堵砖墙,试图阻止 pserve 而不只是杀死进程。

我可以按如下方式在生产模式下启动 pserve:

/usr/bin/python /usr/local/bin/pserve /var/mypath/production.ini start --daemon --pid-file=/var/lock/watermark.pid --log-file=/var/www/5000.log --monitor-restart http_port=8080

但是当我尝试按如下方式停止它时:

/usr/bin/python /usr/local/bin/pserve /var/mypath/production.ini stop --daemon --pid-file=/var/lock/watermark.pid --log-file=/var/www/5000.log --monitor-restart http_port=8080

我收到一个错误:

Traceback (most recent call last):
  File "/usr/local/bin/pserve", line 8, in <module>
    load_entry_point('pyramid==1.5a2', 'console_scripts', 'pserve')()
  File "/usr/local/lib/python2.7/dist-packages/pyramid-1.5a2-py2.7.egg/pyramid/scripts/pserve.py", line 51, in main
    return command.run()
  File "/usr/local/lib/python2.7/dist-packages/pyramid-1.5a2-py2.7.egg/pyramid/scripts/pserve.py", line 229, in run
    result = self.stop_daemon()
  File "/usr/local/lib/python2.7/dist-packages/pyramid-1.5a2-py2.7.egg/pyramid/scripts/pserve.py", line 476, in stop_daemon
    kill(pid, signal.SIGTERM)
OSError: [Errno 3] No such process

任何想法为什么停止命令不起作用?如果有区别的话,它就在 linux ubuntu 机器上。

【问题讨论】:

  • 你确定你的pid文件真的存在吗?你确定它里面的进程id是指你的金字塔应用的进程id吗?
  • .pid 文件是在启动时写入的。我已经根据正在运行的进程和三个 pserve pid 检查了 pid 文件,它是 2 个父进程之一。

标签: python pyramid


【解决方案1】:

1) 获取进程数

ps -ef | grep pserve
testuser 26795     1  0 04:18 ?        00:00:00 /home/testuser/.virtualenvs/testapp/bin/python /home/testuser/.virtualenvs/testapp/bin/pserve production.ini start --daemon --pid-file=watermark.pid --log-file=5000.log --monitor-restart http_port=8080

2) 创建pyramid.pid

touch pyramid.pid && echo "26795" >> pyramid.pid

3) 停止服务 :)

/home/testuser/.virtualenvs/testapp/bin/python /home/testuser/.virtualenvs/testapp/bin/pserve production.ini stop

【讨论】:

  • 这需要是一个自动执行的启动脚本。请参阅上面我对@Antoine-Leclair 的评论,我在其中指出我的 pid 似乎是正确的。看起来金字塔关闭命令并没有停止它。
  • 你不能通过 pserve 停止这个进程,因为他每次都会再次运行。例如你可以这样杀死它:kill -9 `ps -ef | grep "\-pid-file=./watermark.pid" | awk '{print $2}'`
  • 有趣 - 让我试一试,然后回复你
猜你喜欢
  • 1970-01-01
  • 2010-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多