Linux: user defined daemons/services

daemonlinuxservicestartupsysv

I'm looking for a framework/library/environment so an ordinary user can set up it's own server processes. These processes should run under his uid as any other user process.

However the definition of which processes should be started, with arguments they get etc should be specified by an ordinary user without extra privileges. It's important to me that this happens without the necessity for the user to actually log in. Ideally it should work with SYSV init but a systemd-based thing is ok as well.

Examples/use cases:

  • nginx uwsgi/fast cgi processes
  • mongodb instances
  • different builders for continuous integration server

All of these have in common, that I might want to start multiple instances of the same binary (with different parameters) and that these parameters might need regular changes. However users should be able to tweak all of that without requiring root privileges.

Any suggestions/pointers how this can be implemented in Linux?

EDIT: The minimal requirement is just to start the user processes but obviously there will be the need for more advanced control mechanisms. For example there should be an easy way to query if the service is running, stopping the instance, restarting it, reloading it, …

Best Answer

cron provides for this with the @reboot prefix (Vixie, and perhaps other flavors, check man 5 crontab). The user would use crontab to create/edit their own crontab file, and specify

@reboot /some/path/command -flags --moreflags

Which will run that command on startup, as that user.