错误的PID:带软件集合Python的supervisord程序

我有一个Python服务器,必须由启用了软件集合的环境来执行。 supervisordconfiguration文件看起来像这样:

 [program:xxx] command=/usr/bin/scl enable rh-python35 -- /myenv/bin/python server.py stdout_logfile=/var/log/xxx.log redirect_stderr=true 

程序启动正常,但是supervisord认为scl进程是实际进程,但是Python服务器有不同的PID 。 SIGTERM(停止,重新启动等)的时间到了, scl进程终止,但Python服务器继续运行。

可以让我的服务器写一个PID文件,然后使用pidproxy提供的pidproxy程序,如下所述:

http://supervisord.org/subprocess.html#pidproxy-program

然后,如上所述, supervisord会发送信号到正确的PID。 但是,如果可能,我宁愿避免更改服务器代码来创buildPID文件。

问题:有没有其他的方法来设置它?

请注意,直接执行软件集合内的python可执行文件不起作用:

 [user@xxx gpsengine]$ /opt/rh/rh-python35/root/bin/python -V /opt/rh/rh-python35/root/bin/python: error while loading shared libraries: libpython3.5m.so.rh-python35-1.0: cannot open shared object file: No such file or directory 

其他详情:

  • Centos 7

编辑:除了涉及中间shell脚本的pidproxy还有一个额外的方法。 这个邮件列表条目描述了一个enable 脚本 (与scl enable 命令相反):

https://www.redhat.com/archives/sclorg/2016-June/msg00008.html

这可以在shell脚本中使用,如下所示:

 exec 2>&1 test -f /opt/rh/rh-python35/enable && source /opt/rh/rh-python35/enable exec /myenv/bin/python server.py 

由于exec取代了shell进程, supervisord程序configuration可以指向这个shell脚本作为命令。