50

I'm using django-gunicorn-nginx setup by following this tutorial http://ijcdigital.com/blog/django-gunicorn-and-nginx-setup/ Upto nginx setup, it is working. Then I installed supervisor, configured it and then I reboot my server and checked, it shows 502 bad gateway. I'm using Ubuntu 12.04 LTS

/etc/supervisor/conf.d/qlimp.conf

[program: qlimp]
directory = /home/nirmal/project/qlimp/qlimp.sh
user = nirmal
command = /home/nirmal/project/qlimp/qlimp.sh
stdout_logfile = /path/to/supervisor/log/file/logfile.log
stderr_logfile = /path/to/supervisor/log/file/error-logfile.log

Then I restarted supervisor and I run this command $ supervisorctl start qlimp and I'm getting this error

unix:///var/run/supervisor.sock no such file

Is there any problem in my supervisor setup?

Thanks!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
rnk
  • 2,174
  • 4
  • 35
  • 57

12 Answers12

66

That there is no socket file probably means that supervisor isn't running. A reason that it isn't running might be that your qlimp.conf file has some sort of error in it. If you do a

sudo service supervisor start

you can see whether or not this is the case. If supervisor is already running, it will say. And if it is catching an error, it will usually give you a more helpful error message than supervisorctl.

kdazzle
  • 4,190
  • 3
  • 24
  • 27
27

I have met the same issue as you and after several times, here comes the solution:

  1. First remove the apt-get supervisor version:

      sudo apt-get remove supervisor
    
  2. Kill the backend supervisor process:

     sudo ps -ef | grep supervisor
    
  3. Then get the newest version(apt-get version was 3.0a8):

    sudo easy_install(pip install) supervisor==3.0b2 
    
  4. Echo the config file(root premission):

    echo_supervisord_conf > /etc/supervisord.conf
    

5.Start supervisord:

   sudo supervisord

6.Enter supervisorctl:

   sudo supervisorctl

Anything has been done! Have fun!

Scen
  • 921
  • 10
  • 14
18

Try this

cd /etc/supervisor
sudo supervisord
sudo supervisorctl restart all
Anil
  • 967
  • 10
  • 20
  • This worked for me because supervisor is not installed as a service on my server. I need to manually start it after a reboot with `supervisord` before I can use `supervisorctl`. Thank you Anil – OskarD90 Feb 19 '16 at 14:00
  • Worked for me, I have this running inside docker and the sock file looks like it was not created at start, even though supervisord was up in the ps list. "sudo supervisord" seems to kick it to create it, though it threw an warning message that I was running it as root – tristanbailey Mar 04 '16 at 23:24
12

Are you sure that supervisord is installed and running? Is there a socket file in present at /var/run/supervisor.sock?

The error indicates that supervisorctl, the control CLI, cannot reach the UNIX socket to communicate with supervisord, the daemon.

You could also check /etc/supervisor/supervisord.conf and see if the values for the unix_http_server and supervisorctl sections match.

Note that this is a Ubuntu-level problem, not a problem with Python, Django or nginx and as such this question probably belongs on ServerFault.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • No. there is no supervisor.sock file in /var/run Why is it so? – rnk May 23 '12 at 08:50
  • 2
    If `/etc/supervisor/supervisord.conf`, section `unix_http_server` has a file entry pointing to `/var/run/supervisor.sock`, then supervisord is not running or installed. Run `sudo /etc/init.d/supervisor start` to see if it'll start. – Martijn Pieters May 23 '12 at 09:14
  • I tried running `sudo /etc/init.d/supervisor start` and I got error in `path/to` is not found. Then I changed to `/etc/supervisor/log/` Now I got the supervisor.sock file..rebooted and then checked. Still getting **502 bad gateway** – rnk May 23 '12 at 09:30
  • Right, now you have either an nginx configuration problem or your upstream is not running. Try accessing localhost:8001 directly. – Martijn Pieters May 23 '12 at 09:43
10

On Ubuntu 16+ it seems to been caused by the switch to systemd, this workaround may fix for new servers:

 # Make sure Supervisor comes up after a reboot.
 $ sudo systemctl enable supervisor

 # Bring Supervisor up right now.
 $ sudo systemctl start supervisor

and then do check your status of iconic.conf [My example] of supervisor

$ sudo supervisorctl status iconic

enter image description here

PS: Make sure gunicorn should not have any problem while running.

Dinesh Sunny
  • 4,663
  • 3
  • 30
  • 29
5

The error may be due to that you don't have the privilege. Maybe you can fix the error by this way, open your terminal, and input vim /etc/supervisord.conf to edit the file, search the lines

[unix_http_server]
;file=/tmp/supervisor.sock   ; (the path to the socket file)
;chmod=0700                  ; socket file mode (default 0700)

and delete the Semicolon in the start of the string ;file=/tmp/supervisor.sock and ;chmod=0700, restart your supervisord. I suggest you do it.

jfunez
  • 397
  • 6
  • 23
Karl Doenitz
  • 2,220
  • 3
  • 20
  • 38
3

Make sure that in /etc/supervisor.conf the following two sections exists

[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
Yuvaraj Loganathan
  • 781
  • 11
  • 15
2

You can do something like this :-

sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
sudo service supervisor restart

It's definitely work, try this.

Manish Silawat
  • 900
  • 5
  • 7
2

In my case, Supervisor was not running. To spot the issue I run:

sudo systemctl status supervisor.service

The problem was that I had my logs pointing to a non-existing directory, so I just had to create it.

I hope it helps :)

Alan Wagner
  • 2,230
  • 1
  • 16
  • 13
  • Thanks! That solved it for me. Actually, supervisor.conf was okay, but a service file in the `conf.d` folder pointed to a non-existing directory. – Daniel Feb 14 '19 at 14:10
0
touch /var/run/supervisor.sock
sudo supervisord -c /etc/supervisor/supervisord.conf

and after supervisorctl restart all

if you want to listen the supervisor port

ps -ef | grep supervisord

if you want kill the process

kill -s SIGTERM 2503  
ercvs
  • 337
  • 1
  • 5
  • 13
0

Create a conf file and below add lines

Remember that in order to work with Nginx, you must have to disable autostart on system boot, that you activated while installing Nginx.

https://askubuntu.com/questions/177041/nginx-disable-autostart

Note: All the supervisor processes must be on "daemon off" mode, in order to work with supervisor

[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
startretries=5
stopasgroup=true
stopsignal=QUIT
numprocs=1
startsecs=0
process_name=WebServer(Nginx)
stderr_logfile=/var/log/nginx/error.log
stderr_logfile_maxbytes=10MB
stdout_logfile=/var/log/nginx/access.log
stdout_logfile_maxbytes=10MB

sudo supervisorctl reread && sudo supervisorctl update

enter image description here

0

I have faced this error several times -

If server is newly created instance and facing this issue

Might be because of some wrong config or mistake happened during the process, or supervisor is not enabled.

  1. Try restarting your supervisor and reconnecting ec2

    or

  2. Try reinstalling supervisor (@Scen)

    or

  3. Try approaches mentioned by @Yuvaraj Loganathan, @Dinesh Sunny. But mostly you might end up creating a new instance.

If server was running perfectly from long time but then it suddenly stopped

and threw unix:///var/run/supervisor.sock no such file on sudo supervisorctl status.

It may be due to high memory usage, refer below image usage was 99% of 7.69GB earlier.

enter image description here

  1. You can find the above config after connecting with ec2 via ssh or putty at the top.
  2. You can upgrade your ec2 instance or you can then delete any extra files like logs (/var/logs), zip to free up the space. But careful do not delete any system files.
  3. Restart supervisor sudo service supervisor restart
  4. Check sudo supervisorctl status
Ishika Jain
  • 949
  • 2
  • 11
  • 23