我有以下新贵工作:
description "posty api"
start on mysql
stop on shutdown
env RACK_ENV=production
setuid vmail
setgid vmail
chdir /opt/posty_api
pre-start script
mkdir -p /var/run/posty
chown -R vmail:root /var/run/posty
end script
exec /usr/local/bin/unicorn -D -c /opt/posty_api/unicorn.rb --env production >> /var/log/posty/upstart.log 2>&1
post-stop exec kill `cat /var/run/posty/unicorn.pid`
respawn
respawn limit 1 10
要在其中创建文件夹,/var/run
我需要root权限。如何以root用户身份运行upstart作业的某些部分,如何以非特权用户身份运行服务本身?
upstart
没有与systemd
的PermissionsStartOnly
设置等效的功能。在作业的所有进程运行为通过用户设定的setuid
节,如食谱说。
daemontools方式也是如此。
使用setuidgid
,setuidgid
,s6-setuidgid
,chpst
,runuid
,或setuidgid
在exec
节:
exec \ setuidgid某人\ unicorn -D -c /opt/posty_api/unicorn.rb --env生产>> /var/log/posty/upstart.log 2>&1
顺便说一下,这是一个糟糕的日志记录机制。该daemontools的方式将有一个适当的,自动循环,rotateable点播,大小皑皑,登录使用multilog
,multilog
,s6-log
,svlogd
,tinylog
,或cyclog
。upstart
但是,鉴于其expect
机制,将它们与这些元素集成是很棘手的。
期望fork 执行器\ setuidgid有人\ 独角兽-D -c /opt/posty_api/unicorn.rb --env production 2>&1 | \ / usr / local / bin / chdir / var / log / \ setuidgid日志\ cyclog posty / unicorn /
(这chdir
是从nosh
包装中装入链的链,并非绝对必要。但这会使事情变得更整洁。)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句