Michael
Michael

Reputation: 921

Supervisor no such file socket.py

I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run supervisorctl reload:

error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228

The file DOES exist. If try to run sudo supervisorctl I get this unix:///var/run/supervisor.sock no such file.

I've tried reinstall supervisor and that did not work either. Not sure what to do here.

I'm running Laravel Homestead (Ubuntu 16.04).

Result of service supervisor status:
vagrant@homestead:~/Code$ sudo service supervisor status ● supervisor.service - Supervisor process control system for UNIX Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Thu 2016-12-22 11:06:21 EST; 41s ago Docs: http://supervisord.org Process: 23154 ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown (code=exited, status=0/SUCCESS) Process: 23149 ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf (code=exited, status=2) Main PID: 23149 (code=exited, status=2)

Upvotes: 42

Views: 71310

Answers (16)

Jonathan Jusczyk
Jonathan Jusczyk

Reputation: 1

My problem turned out to be an invalid directory specified in a conf.d file (in my case, the Horizon package in the Laravel framework).

[program:horizon]
process_name=%(program_name)s
command=php /var/www/projects/myInvalidPath/artisan horizon
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/www/projects/myInvalidPath/storage/logs/horizon.log
stopwaitsecs=3600

This invalid config would throw error: <class 'FileNotFoundError'>, [Errno 2] No such file or directory: file: /usr/lib/python3/dist-packages/supervisor/xmlrpc.py line: 560

Interestingly, a far more useful error is reported if the logfile is invalid, which led me to the discovery:

ERROR: CANT_REREAD: The directory named as part of the path /var/www/projects/myInvalidPath/storage/logs/horizon.log does not exist in section 'program:horizon' (file: '/etc/supervisor/conf.d/horizon.conf')

Upvotes: 0

Akonobi
Akonobi

Reputation: 31

On Centos 7 I use the following...

supervisord -c /path/to/supervisord.conf

followed by...

supervisorctl -c /path/to/supervisord.conf

This gets rid of the ".sock file not found" error. Now you have to kill old processes using...

ps aux|grep gunicorn

Kill the offending processes using...

kill <pid>

Then again...

supervisorctl -c /path/to/supervisord.conf

Supervisor should now be running properly if your config is good.

Upvotes: 3

Fokwa Best
Fokwa Best

Reputation: 3515

I did the following to solve the issue on CentOS Linux 7

sudo systemctl status supervisord.service

With the above command, I realise that the program was in active

sudo systemctl start supervisord.service

Now I use the command above to start the service and everything works well now

Upvotes: 0

Mihir Bhatt
Mihir Bhatt

Reputation: 3155

Source of answer : http://supervisord.org/installing.html

  1. Run command : echo_supervisord_conf
  2. Once you see the file echoed to your terminal, reinvoke the command as echo_supervisord_conf > /etc/supervisord.conf. This won’t work if you do not have root access.
  3. If you don’t have root access, or you’d rather not put the supervisord.conf file in /etc/supervisord.conf, you can place it in the current directory (echo_supervisord_conf > supervisord.conf) and start supervisord with the -c flag in order to specify the configuration file location.

The error should've been resolved by now.

Upvotes: 0

Arash Younesi
Arash Younesi

Reputation: 1760

None of about answers helped me. the problem was i didn't follow supervisor documentation. and a step i didn't do was run echo_supervisord_conf command that makes the configuration file.

Steps i did for Ubuntu 18.04:

Installing supervisor (without pip):

  1. sudo apt-get install supervisor
  2. echo_supervisord_conf > /etc/supervisord.conf (with root access: first run sudo -i then echo_supervisord_conf > /etc/supervisord.conf)
  3. change python dependency to python2

(Depends: python-pkg-resources, init-system-helpers (>= 1.18~), python-meld3, python:any (<< 2.8), python:any (>= 2.7.5-5~)

in these files: /usr/bin/supervisord | /usr/bin/supervisorctl | /usr/bin/echo_supervisord_conf. Just change the first line from #!/usr/bin/python to #!/usr/bin/python2

  1. run supervisord
  2. Finish

hope help !

Upvotes: 5

Mathiouss
Mathiouss

Reputation: 101

If by running sudo service supervisor status you get the following:

ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf (code=exited, status=2)

Try running /usr/bin/supervisord, it will give you clear message to tell you where the error is.

Upvotes: 2

Kiran Patel
Kiran Patel

Reputation: 379

Facing the python file not found an error, code=exited, status=2 once I try with the official document but still same. I have tried so many solutions for my laravel application.

But at last, I have tried with my solution.

Here is an example for the code :

[program:dev-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/example.com/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=ubuntu
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/example.com/storage/logs/laravel.log
stopwaitsecs=3600

Ref: https://laravel.com/docs/7.x/queues#supervisor-configuration

Upvotes: 3

Jason
Jason

Reputation: 87

I had a very similar problem (Ubuntu 18.04) and searched similar threads to no avail so answering here with some more comprehensive answers.

Lack of a sock file or socket error is only an indicator that supervisor is not running. If a simple restart doesn't work its either 1. not installed, or 2. failing to start. In my case nothing was being logged to the supervisor.log file for me to know why it was failing until I ran the following command (-n to run in foreground) only to find out that there was a leftover configuration file for a project that had been deleted that I missed.

/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf

Once I deleted the bad/leftover file in the conf.d folder and started it back up with sudo service supervisor start everything worked.

Here are some comprehensive steps you can take.

  1. Is supervisor installed? dpkg -l | grep supervisor If not reinstall sudo apt install supervisor
  2. Are all instances of supervisor stopped? systemctl stop supervisor Lingering supervisor processes can be found ps aux | grep supervisor then kill -9 PID.
  3. Is supervisor.conf in the right location /etc/supervisor/supervisor.conf and there are no syntax errors? Reinstall from package would correct this.
  4. Move your specific files in conf.d/ temporarily out of the folder to try and start with no additional config files. If it starts right up sudo service supervisor start the likelihood of an error in your project .conf file exists.
  5. Check status with sudo service supervisor status.
  6. Move your .conf files one by one back into conf.d/ and restart sudo service supervisor restart. Be sure to check with sudo service supervisor status between. If it fails you know which .conf file has an issue and can ask for specific help.
  7. check everything is running with supervisorctl status and if not start with supervisorctl start all.

Upvotes: 5

KaungThant
KaungThant

Reputation: 21

You can try by removing all of the related folder of supervisor & uninstall supervisor completely.

sudo rm -rf /var/log/supervisor/supervisord.log 
sudo rm -rf /etc/supervisor/conf.d/ 

After doing this, reinstall supervisor by

sudo apt install supervisor

Now, you can run correctly. Check with

sudo systemctl status supervisor

Upvotes: 2

Madacol
Madacol

Reputation: 4276

In Ubuntu 18.04 with distribution's package

You probably did the same mistake as me an created the config file /etc/supervisord.conf while my service manager (systemd) was using the config file /etc/supervisor/supervisord.conf

Solutions

  • Remove the config file created

    sudo rm /etc/supervisord.conf
    
  • Move it to the correct location

    sudo mv /etc/supervisord.conf /etc/supervisor/supervisord.conf
    

Now you can run sudo supervisorctl


Why?

when you run supervisorctl it first searches for the config file located at /etc/supervisord.conf, if it's not present, it will search for the package's default file /etc/supervisor/supervisord.conf this is the one systemd actually runs.

Systemd always use the file /etc/supervisor/supervisord.conf regardless of the other file's existence.

You can check which file is using systemd by running sudo systemctl status supervisor

enter image description here You can see in the last line the command where the config file is hardcoded

Upvotes: 13

D. Erik Goodman
D. Erik Goodman

Reputation: 31

I ran into this issue because we were using supervisorctl to manage gunicorn. The root of my problem had nothing to do with supervisor (it was handling other processes just fine) or the python sock.py file (file was there, permissions were correct), but rather the gunicorn config file /etc/supervisor/conf.d/gunicorn.conf. This configuration file was managed by a source-controlled template with environment variables and when we updated the template on the server, the template variables were never replaced with the actual data. So for example something in the gunicorn.conf file read user={{ user }} instead of user=gunicorn. When supervisor tried to parse this config when running supervisorctl start gunicorn it would crash with this socket error. Repairing the gunicorn.conf file resolved the supervisor issue.

Upvotes: 0

nwaweru
nwaweru

Reputation: 2034

2020 UPDATE

Try running sudo service supervisor start in your terminal before using the below solution. I found out that the issue sometimes occurs when supervisor is not running, nothing complicated.

I am using Ubuntu 18.04. I had the same problem and re-installing supervisor did not solve my problem.

I ended up completely removing the conf.d directory and recreating it with new configs. Make sure you back up your configurations before trying this:

  1. sudo rm -rf /etc/supervisor/conf.d/
  2. sudo mkdir /etc/supervisor/conf.d
  3. sudo nano /etc/supervisor/conf.d/my-file.conf
  4. Copy+Paste your configuration into your new file.

sudo supervisorctl reread started working again.

Upvotes: 29

Somansh Reddy
Somansh Reddy

Reputation: 135

Check the supervisord.conf file.

Look for the following:

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

Go to the path mentioned above and check if the file is present.
If it is present then try re-installing supervisor.

If not then search for supervisor.sock file either using the command line or file explorer GUI.

Copy the file found in the above step to the location specified in the [unix_http_server] by using the cp command or GUI.

For me, the supervisor.sock was present in the /run folder.

Upvotes: 1

Galdil
Galdil

Reputation: 589

You should run sudo service supervisor start when you are in the supervisor dir.
Worked for me.

Upvotes: 48

Fanley
Fanley

Reputation: 61

you can try

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

Upvotes: 0

Michael
Michael

Reputation: 921

I ended up just removing supervisor entirely, reinstalling and rewriting my config files. I must have just done something wrong in the process and wasn't able to catch it.

Upvotes: 2

Related Questions