Supervisor - Can't start supervisorctl as root or user (User is set in config)

24,064

Solution 1

I added my username to the superisord.conf file under the [unix_http_server] section like so:

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)
chown=appuser:supervisor        ;(username:group)

This seemed to work- time will tell if it continues working after I manage solve the rest of the supervisor issues.

Solution 2

Adding more to Adam's solution.

you need to give the group permissions to read/write to the socket too.

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0770                       ; sockef file mode (default 0700)
chown=appuser:supervisor        ;(username:group)
Share:
24,064
Adam Starrh
Author by

Adam Starrh

Self-taught hobbyist learning Python & Django for my businesses and orgs. Check out my business startups: OTHERLANE -- EconAbuse.org -- Almond King

Updated on July 11, 2022

Comments

  • Adam Starrh
    Adam Starrh almost 2 years

    I start supervisor as root:

    sudo supervisord -c /etc/supervisor/supervisord.conf

    Then I try to start up supervisorctl:

    (myapp)appuser@ip-172-31-21-65:~/appuser$ supervisorctl -c /etc/supervisor/supervisord.conf
    

    Supervisor starts with the following mesage:

    error: <class 'socket.error'>, [Errno 13] Permission denied: file: /usr/lib/python2.7/socket.py line: 224
    

    Trying to run the second command as root is also unsuccessful. My understanding is that this is by design.

    All the advice I find suggests that I should set my user as the user that executes the command, but this is already how I have it all configured:

    Here is the script file that I am using:

    NAME="myapp"                              
    DJANGODIR=/home/appuser/myapp             
    SOCKFILE=/home/appuser/myapp/gunicorn.sock        
    USER=appuser                                        
    GROUP=webdata                                     
    NUM_WORKERS=1                                     
    DJANGO_SETTINGS_MODULE=myapp.settings             
    DJANGO_WSGI_MODULE=myapp.wsgi  
    

    I'm not sure what is screwing it up? I think it might be the GROUP setting, as I don't recognize that value. But if I comment it out, it doesn't seem to make a difference. How should I troubleshoot this?

    EDIT: I created a group named supervisor, added appuser to it and changed the GROUP setting to match, but still no joy.

    This is my supervisord.conf:

    ; supervisor config file
    
    [unix_http_server]
    file=/var/run/supervisor.sock   ; (the path to the socket file)
    chmod=0700                       ; sockef file mode (default 0700)
    
    [supervisord]
    logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/super$
    pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
    childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TE$
    
    [rpcinterface:supervisor]
    supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
    
    [supervisorctl]
    serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket
    
    [include]
    files = /etc/supervisor/conf.d/*.conf
    

    And my configuration file for the app:

    [program:myapp]
    command = /home/appuser/myapp/gunicorn_start.sh ; Command to start app
    user = appuser ; User to run as
    stdout_logfile = /home/appuser/myapp/logs/supervisor.log ; Where to write$
    redirect_stderr = true ; Save stderr in the same log
    environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8 ; Set UTF-8 as default encoding
    

    My supervisor version is:

    >supervisord --version
    3.0b2
    
  • imer
    imer over 7 years
    I know this is an old question, but for anyone coming across this: you need to give the group permissions to read/write to the socket too. So change chmod=0700 to chmod=0770