How to Solve Error Message error: , [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224 when running supervisor in Linux CentOS

Posted on

Introduction

Actually, this is also another article discussing about how to solve an error message. This is actually not an error message where the solving step is in a specific action or solution. Instead, there is a sequence on executing the supervisor command before a certain command can work normally. Before further going on, supervisor itself is a tool where it is is a client/server system. It allows its users to monitor and control several processes on UNIX-like operating systems. Furthermore, it is also useful to control processes and it is an utility to to start program or service at boot time. There is an article for further reference in installing supervisor tool. It exist in this link with the title of ‘How to Install supervisord in Linux CentOS 7’. The following is the actual command execution which is causing the error message to appear :

[root@localhost etc]# supervisorctl reread
error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224
[root@localhost etc]#

After the installation of the supervisor tool is a success, there is an additional step to change the supervisor configuration file. Normally, that yum configuration file exist in /etc/yum.conf. It is a command execution after configuring or changing the supervisor configuration file exist by adding the following entries in the bottom part of the file with the ‘program:gunicorn’ block :

...
...
...
[program:gunicorn]
directory=/home/django/project/myapps
command=/home/django/project/env/bin/gunicorn --workers 3 --bind unix:/home/django/project/myapps/apps.sock apps.wsgi:application
autostart=true
autorestart=true
stderr_logfile=/var/log/gunicorn/gunicorn.out.log
stdout_logfile=/var/log/gunicorn/gunicorn.err.log
user=root
group=django
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8
[group:guni]
programs:gunicorn

Well, it does not have any direct impact to the error appear, but the command ‘supervisorctl reread’ is a command useful to instruct supervisor to read again the changes exist in the supervisor configuration file.

Actually, the contnet

Solution

So, the problem which is causing the problem above is just a matter of command sequence execution. In this case, there is a command execution using ‘supervisor’. Apparently, the solution is very simple. The error appear as soon as the installation of ‘supervisor’ is in a success as in the article in this link, changing the supervisor configuration file and execution the ‘supervisor reread’ command to instruct supervisor to read the changes exist in it. But in order for supervisor to do that, the supervisor service must be active and running while in this case it is not. This is a simple mistake where the supervisor service is not active and triggering the error. So, the solution is very easy. Just make sure the supervisor service is running. If it is not, just run the command for running the supervisor service. The command ‘supervisorctl reread’ will run properly if the supervisor service is currently running. So, run it as below :

[root@localhost ~]# systemctl start supervisord
[root@localhost ~]# systemctl status supervisord
● supervisord.service - Process Monitoring and Control Daemon
   Loaded: loaded (/usr/lib/systemd/system/supervisord.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-11-25 16:54:22 UTC; 3s ago
  Process: 2206 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=0/SUCCESS)
 Main PID: 2209 (supervisord)
   CGroup: /system.slice/supervisord.service
           ├─2209 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
           ├─2219 /home/django/project/env/bin/python /home/django/project/env/bin/gunicorn --workers 3 --bind unix:/home/django/project/myapps/apps.sock apps.wsgi:appl...
           ├─2222 /home/django/project/env/bin/python /home/django/project/env/bin/gunicorn --workers 3 --bind unix:/home/django/project/myapps/apps.sock apps.wsgi:appl...
           └─2224 /home/django/project/env/bin/python /home/django/project/env/bin/gunicorn --workers 3 --bind unix:/home/django/project/myapps/apps.sock apps.wsgi:appl...
Nov 25 16:54:22 localhost systemd[1]: Starting Process Monitoring and Control Daemon...
Nov 25 16:54:22 localhost systemd[1]: Started Process Monitoring and Control Daemon.
[root@localhost log]# supervisorctl reread
No config updates to processes
[root@localhost log]#

Leave a Reply