我有一个Tornado程序,并且所有相关的Python库都安装在名为Bob的非root用户中:
pip install --user xxx
现在我想在supervisor中运行它:
[program:testpro]
command=python /path/to/myfile.py
user=bob ; set the user to bob
redirect_stderr=true
stdout_logfile=/path/to/log
numproces=1
autostart=true
但是它在 supervisorctl status 中失败了:
testpro FATAL Exited too quickly (process log may have details)
我查看了日志,发现它无法导入相对于Python库的模块,因此它并没有像Bob一样运行。
然后我进行了更改:
[program:testpro]
command=sudo -u bob -i python /path/to/myfile.py
;user=bob ;comment this
redirect_stderr=true
stdout_logfile=/path/to/log
numproces=1
autostart=true
它正常运行了。
那么,选项user
是做什么的?如何在选项中配置运行用户?
[fcgi-program:foo]
,您可能需要将套接字的用户设置为 _www-data_。以下是有效的设置方式:[fcgi-program:foo]
user=www-data
environment=USER="www-data"
# 其余选项
- uKolka