我有以下新贵的工作:
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
Run Code Online (Sandbox Code Playgroud)
要在/var/run
我需要 root 权限中创建文件夹。如何以 root 身份运行 upstart 作业的某些部分,而以非特权用户身份运行服务本身?
upstart
没有与systemd
的PermissionsStartOnly
设置等效的设施。在作业的所有进程运行为通过用户设定的setuid
节,如食谱说。
所以用 daemontools 的方式做事。
在节中使用setuidgid
, setuidgid
, s6-setuidgid
, chpst
, runuid
, 或:setuidgid
exec
执行\ setuidgid 某人\ unicorn -D -c /opt/posty_api/unicorn.rb --env production >> /var/log/posty/upstart.log 2>&1
顺便说一下,这是一个糟糕的日志记录机制。该daemontools的方式将有一个适当的,自动循环,rotateable点播,大小皑皑,登录使用multilog
,multilog
,s6-log
,svlogd
,tinylog
,或cyclog
。 upstart
然而,考虑到它的expect
机制,很难与它们集成。
期待叉子 执行\ setuidgid 某人\ unicorn -D -c /opt/posty_api/unicorn.rb --env 生产 2>&1 | \ /usr/local/bin/chdir /var/log/ \ setuidgid 日志 \ 独角兽/独角兽/
(chdir
这里是nosh
包装中的链式装载,并不是绝对必要的。但它使事情变得更整洁。)
归档时间: |
|
查看次数: |
9149 次 |
最近记录: |