Skip to content

Instantly share code, notes, and snippets.

@sethsandaru
Last active December 20, 2024 14:16
Show Gist options
  • Save sethsandaru/14d943c592b0c17e4cb8512938defcd0 to your computer and use it in GitHub Desktop.
Save sethsandaru/14d943c592b0c17e4cb8512938defcd0 to your computer and use it in GitHub Desktop.
Run supervisor for ubuntu's user without sudo
While many of our readers will get away with running the command again with sudo, and succeeding, there is a better way! The permission error stems from access permissions to supervisord’s socket file, which by default is owned by root, and not writeable by other users. We can make supervisord chown and chmod the file to a particular user or group on startup, granting the user or group permission to stop and start the services we’ve configured without requiring sudo.
Let’s create a group, add ourselves to it by doing the following
groupadd supervisor
usermod -a -G supervisor
After logging-out/logging-in (so that the new group membership takes effect), edit the supervisord configuration file (/etc/supervisor/supervisor.conf) to make the unix_http_server section look as follows
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0770 ; socket file mode (default 0700)
chown=root:supervisor
Notice that we have chmod’ded the file to 0770 (writeable by owner and group), and chowned the file to root:supervisor, which will allow members of the supervisor group to make calls to supervisorctl. We must restart supervisord one last time
supervisorctl reload
or
sudo service supervisor restart
@yordanoweb
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment