Supervisor no such file socket.py - laravel

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)

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

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:
sudo rm -rf /etc/supervisor/conf.d/
sudo mkdir /etc/supervisor/conf.d
sudo nano /etc/supervisor/conf.d/my-file.conf
Copy+Paste your configuration into your new file.
sudo supervisorctl reread started working again.

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
You can see in the last line the command where the config file is hardcoded

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.
Is supervisor installed? dpkg -l | grep supervisor If not reinstall sudo apt install supervisor
Are all instances of supervisor stopped? systemctl stop supervisor Lingering supervisor processes can be found ps aux | grep supervisor then kill -9 PID.
Is supervisor.conf in the right location /etc/supervisor/supervisor.conf and there are no syntax errors? Reinstall from package would correct this.
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.
Check status with sudo service supervisor status.
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.
check everything is running with supervisorctl status and if not start with supervisorctl start all.

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):
sudo apt-get install supervisor
echo_supervisord_conf > /etc/supervisord.conf (with root access: first run sudo -i then echo_supervisord_conf > /etc/supervisord.conf)
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
run supervisord
Finish
hope help !

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

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.

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

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.

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.

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.

you can try
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock

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.

Source of answer : http://supervisord.org/installing.html
Run command : echo_supervisord_conf
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.
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.

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

Related

Failed to restart supervisor.service: Unit not found CentOS 7

I am trying to use laravel queue:work on live server and keep alive the work using Supervisor. After configuration it shows as follows:
[root#vmi485931 supervisord.d]# sudo supervisorctl reload
Restarted supervisord
[root#vmi485931 supervisord.d]# sudo service supervisor restart
Redirecting to /bin/systemctl restart supervisor.service
Failed to restart supervisor.service: Unit not found.
Any clue?
there are some package missing in Centos 7. i had some issue on centos 7 and i fixed issue with this commands :
1- need python-meld3 package
sudo rpm -ivh https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/p/python-meld3-0.6.10-1.el7.x86_64.rpm
2-needs supervisor lib.
sudo rpm -ivh https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/s/supervisor-3.4.0-1.el7.noarch.rpm
If you are trying to restart the processes that are run by supervisor, run
sudo supervisorctl restart all
You can use supervisor process name instead of 'all' to restart a specific process.
If you are trying to restart supervisor itself,sudo systemctl restart supervisor should work.

Rundeck debconf-set-selection:

I'm using Rundeck 3.2.6-20200427 and set up a job for installing packages.
Because rundeck runs noninteractive I need to preset some parameters for installing packages (in my case iptables-persistent).
Before installing the package I run that command (for now only this parameter, I will use more parameters if I got that working):
echo iptables-persistent iptables-persistent/autosave_v4 boolean false | sudo debconf-set-selections
Unfortunatelly I got that error if I run rundeck-command
09:09:08 debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
09:09:08 Failed: NonZeroResultCode: Remote command failed with exit status 1
I'm absolute sure that there are no other task or running dpkg related process.
~$ lsof /var/cache/debconf/config.dat
~$
If I try to run that command directly, it works without any error. So I don't understand, why it is not working with rundeck.
I tried that on freshly installed host where I try to install packages (Ubuntu Server 20.04).
Here is my job definition: https://pastebin.com/YSu545tX
I found out that in the node-file, there was a typo so the job was running on wrong host and there were an apt-process, which was stuck.
There I checked with that command:
~$ sudo fuser -v /var/cache/debconf/config.dat
USER PID ACCESS COMMAND
/var/cache/debconf/config.dat:
root 5563 F.... frontend
Then I killed that process and corrected the node-file. Now it works.
I meet the same problem, but both 'fuser' and 'lsof' show nothing. finally finds out is dpkg lock that file, and use
ps aux | grep dpkg
to find that process and kill it.

`dpkg --configure -a` hangs

I'm using Ubuntu 16.04.
When I update, I got the following message
$ sudo apt-get update
....
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
Following the error message, I try
$ sudo dpkg --configure -a
setting up snapd (2.14.2~16.04) ...
then it hangs forever.
Does anybody know how can I fix this problem?
Thanks.
This is a confirmed bug.
https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1621336
A workaround is listed:
https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1621336/comments/4
Adding the workaround from Axel Kämpfe since the links seems to be broken:
Start a rootshell with "sudo -i"
Run echo "bash -c 'service snapd.boot-ok start'" | at now + 4 min
Then run apt install snapd (if it argues about canceled dpkg processes use the dpkg --configure -a. Then wait for at least 4 minutes. The hanging should gone then.
Good luck! :)
/Patrik
I had a similar problem twice and I have noticed that it happens everytime my system wants to upgrade to a new Kernel. The steps below seem to work for me all the time;
Boot into the recovery mode of your newest kernel versions.
Log-in to the system as root from the drop-down menu.
Edit the /etc/resolv.conf file using a text editor, I normally use vi, i.e.
vi /etc/resolv.conf
and put in the contents below and save file;
nameserver 208.67.222.220
nameserver 208.67.222.222
After the above step, Ctrl+D (exit) back into the recovery mode menu and click on networking to enable network/internet connection.
Next, click on the dpkg item to fix broken packages.
That's it, after the reboot your system should have the right kernel install and broken packages fixed/removed.
Identify the application that is causing the dpkg --configure -a hanging error.
Example: snapd
Execute the following command:
sudo apt-get remove snapd
In my case, I entered the following command:
sudo apt-get remove mysql-server-8.0
Re-install the application if necessary.
I hope this helps you too. Health!

Can't start ceph service

I working on CentOS7 and I install ceph by manual build
./autogen.sh
./configure
make
make install
and manual deploy by follow this link http://ceph.com/docs/master/install/manual-deployment/
but ceph doesn't exist in directory /etc/rc.d/init.d/
Failed to issue method call: Unit ceph.service failed to load: No such
file or directory
So, I can't start service.
In document of manual deploy it's said I have to use command
sudo /etc/rc.d/init.d/ceph start mon.node1
In CentOS7 use systemd
So, use command sudo systemctl start ceph-osd#0 will work!!!
You can run systemctl status ceph* as a quick way to show any services on the box or systemctl list-units --type=service | grep ceph the service name syntax is ceph-mon#<hostname>.service or ceph-osd#<osd_num>.service
Please run systemctl list-unit-files and you can list all ceph services and you must find OSD number with ceph osd tree and put in this command systemctl status ceph-osd#{OSD_NUM}.target

Clamav installation steps for linux centos

I have tried to install clamav in linux centos, but not able to succeed, so anybody provide me the procedure to install clamav antivirus and test the same.
Thanks in advance
First thing to do is install the program sudo apt-get install clamav
It´s necessary install the deamon program as well sudo apt-get install clamav-daemon
Once that we have the program properly installed, will be necessary configure to make it works with our app. /etc/clamav/clamd.conf
TCPAddr 127.0.0.1
TCPSocket 3310
To configure by console the antivirus just type sudo dpkg-reconfigure clamav-freshclam
Restart the service sudo /etc/init.d/clamv-* restart
For CentOS 6
Install ClamAV via yum epel repo:
yum install clamd
Edit config file:
vim /etc/clamd.conf
ExtendedDetectionInfo yes
ExcludePath /usr/local/maldetect/
DetectPUA yes
Set to start on boot:
chkconfig clamd on
Update ClamAV prior to a scan:
freshclam
Start ClamAV:
service clamd start
Add the cron for daily automatic scans:
vim /etc/cron.daily/daily-clamscan
#!/bin/bash
SCAN_DIR="/"
LOG_FILE="/var/log/clamav/daily-clamscan.log"
/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE
Set proper cron permissions:
sudo chmod +x /etc/cron.daily/daily-clamscan
Update the logrotate file to look for all logs via wildcard
vim /etc/logrotate.d/daily-clamscan
/var/log/clamav/daily-clamscan.log {
missingok
notifempty
create 644 clam clam
}
Thats how I installed it on my machine. Here are a few good quick commands or you can use the cron to manually run it. I also installed Linux Malware Detect (LMD) with it so I can do more for my scans.
Full System Scan that only displays infected files and runs in the background with bell
Use jobs command to view status
clamscan -r --bell -i / &

Resources