i have ubuntu 14.04 lts server running few different programs under supervisor. many of programs need store sockets , other named pipes on filesystem, , /run seems ideal choice these types of files. unfortunately, /run tmpfs , removed on every reboot, , root privileges needed (re)create directories each program can write to.
i need way create few subdirectories in /run , set owner/mode each program can work with, , on each reboot before supervisor tries start them. not supervisor supports mechanism run pre-start commands before starts program.
most other answers type of question suggest doing in init script, belongs supervisor's package , not want mess (or have maintain when changes upstream).
if machine had systemd seems use /etc/tmpfiles.d, not.
the best idea came use separate upstart pre-start script each program creates directories without launching processes. like:
/etc/init/myapp1.conf
start on runlevel [2345] pre-start script mkdir -p -m 0755 /var/run/myapp1 chown app1user: /var/run/myapp1 end script ...without exec line. i'm not 100% sure valid or sane, appears work. there cleaner ways this?
do run apps under supervisor under specific user? because default applications run root owner.
what simple script following:
- checks if required files/folders created.
- sets owner if necessary.
- then starts application
put script supervisor config instead of directly starting application. make sure run root (remove user config or set user=root).
this way can make sure environment set , directories exist. if clear tempfs reasons, scripts still run without reboot.
if need run applications under specific user, can following:
- move first 2 points separate setup script (as using solution).
- create script calls setup script sudo , starts application
- add custom user , script sudo file user can call script root without password prompt. (be aware: security risk, if gets access server. make sure setup script not writable)
Comments
Post a Comment