A thing I frequently want to do is launch some long running process or server as my own non-privileged user and then have a way to tell if it's still running and restart it if not.
So for example I might set a cron job that runs every so often checking if my process is running and restart it if it has crashed. This is the essence of process management tools like djb's daemontools, supervisord, launchd etc. except that those tools are configured by default to run as root with config files in /etc
but I would like a utility that lets me do the same sort of thing as my non-privileged user from the comfort of my home directory.
Best Answer
deamontools
you mentioned work just fine as user. See https://cr.yp.to/daemontools/supervise.htmlUpdate - solutions
as per the above suggestion the OP got this working using the
svscan
program fromdaemontools
after trying two different methods:@reboot /usr/bin/svscan $HOME/.local/service 2>&1 > $HOME/.local/service/log
Make
~/.config/autostart/svscan.desktop
with theExec=...
line set to launchsvscan
with a wrapper script. My wrapper script looks like this:Both methods work but each is good for a different situation. The first way is good if you're doing it on a headless machine where you want to allow a non-privileged user to install their own long running services and processes. The second way is good if you want all of the services to inherit the environment, ssh-agent etc. of your currently logged in X user, which means the processes effectively become a proxy of the currently logged in user themself.