Recommended way to start supervisord from non-root bash script

rootsupervisord

I have set up supervisor to monitor some processes. Because I deploy via remote script, I need a way to send supervisor start/stop commands without sudo. I'm not sure how to do this though.

Is there a way in supervisor to run specified commands as a non root user?

Best Answer

The supervisorctl command can be run as a non-root user. All you need to do is give it permission to connect to the supervisord process.

You'll need to configure access in the appropriate server section, so in the [unix_http_server] section, or in the [inet_http_server] section, whichever you are using for your supervisord setup.

If you use the [unix_http_server] setup, you'd add chmod and/or chown directives to control who can access the UNIX domain socket, for example:

[unix_http_server]
chown = youruser

so that youruser can write to that socket, which means supervisorctl can send supervisord commands. You can also add a group:

[unix_http_server]
chown = youruser:yourgroup

Finally, you'll have to restart supervisord itself with service supervisor restart