服务默认root在我的RHEL框上启动时启动.如果我没记错的话,对于使用init脚本的其他Linux发行版也是如此/etc/init.d.
您认为最好的方法是让流程作为我选择的(静态)用户运行?
我到达的唯一方法是使用类似的东西:
su my_user -c 'daemon my_cmd &>/dev/null &'
Run Code Online (Sandbox Code Playgroud)
但这似乎有点凌乱......
是否有一些隐藏的魔法可以提供一种简单的机制来自动启动服务,就像其他非root用户一样?
编辑:我应该说我在这个实例中开始的过程是Python脚本或Java程序.我宁愿不在它们周围写一个原生包装器,所以不幸的是我无法像Black建议的那样调用setuid().
我使用主管来运行uWSGI应用程序.为什么uWSGI应用程序在停止主管后并不总是停止?主管配置:
[program:test]
autostart = true
user=root
command=uwsgi --master --workers 5 --disable-logging --socket 127.0.0.1:8888
--module web --callable app
priority=1
redirect_stderr=true
stdout_logfile = /data/log
Run Code Online (Sandbox Code Playgroud) 我希望能够pdb在uWSGI下调试Python(Django)应用程序,并且我基本上遇到了与此处描述相同的问题:
...
File "/usr/lib/python2.7/bdb.py", line 49, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/lib/python2.7/bdb.py", line 68, in dispatch_line
if self.quitting: raise BdbQuit
BdbQuit
Run Code Online (Sandbox Code Playgroud)
不同的是,我有不同的uWSGI设置,好像我不能让uWSGI以honour-stdin作为从上面的问题接受的答案建议.
我的设置如下:
1)我有一个systemd进程在Emperor模式下启动uWSGI
[Unit]
Description=uWSGI Emperor service
[Service]
ExecStart=/usr/local/bin/uwsgi --ini /etc/uwsgi/emperor.ini
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
2)/etc/uwsgi/emperor.ini看起来像这样:
[uwsgi]
emperor = /etc/uwsgi/sites
uid = www-data
gid = www-data
limit-as = 1024
logto = /tmp/uwsgi-emperor.log
# I've tried adding both honour-stdin
# and daemons-honour-stdin here
honour-stdin = true …Run Code Online (Sandbox Code Playgroud)