Use supervisor in ubuntu

This article is automatically synchronized by Tencent Cloud + Community, the original address is https://stackoverflow.club/article/use_supervisor_in_ubuntu/

1. installation#

sudo apt install supervisor

2. Configure a program#

The example is as follows, create redsocks2.conf under the directory /etc/supervisor/conf.d/, and add:

[ program:redsocks2]
command     =/home/wenfeng/bin/redsocks2 -c /home/wenfeng/conf/redsocks2.conf
autostart =true
autorestart =true
redirect_stderr         =true
stdout_logfile_maxbytes = 50MB
stdout_logfile_backups  =10
stdout_logfile          =/var/log/supervisor/redsocks2.log

3. Run a program#

If you just put the conf file in the /etc/supervisor/conf.d/ directory, restart supervisor for identification

sudo service supervisor restart

Then start our program

sudo supervisorctl start awesome

If supervisor encounters an error, you can view the log in /var/log/supervisor/supervisord.log;

If there is a problem with the app, you can view the log in /srv/awesome/log/app.log.

4. other#

Supervisor always exits when running ssh tunnel

[ program:gpu_ssh_tunnel]
command     =/usr/bin/ssh  -C2qTnN -D 1080 gpu_name@gpu_domin -i /home/wenfeng/.ssh/id_rsa
autostart =true
autorestart =true
redirect_stderr         =true
stdout_logfile_maxbytes = 50MB
stdout_logfile_backups  =10
stdout_logfile          =/var/log/supervisor/gpu_ssh_tunnel.log

supervisorctl status display

gpu_ssh_tunnel                   FATAL     Exited too quickly(process log may have details)

Build your own monitoring script

#! /bin/bash
whiletruedo
	procnum=`ps -ef| grep 'your_name@your_domin' | grep -v grep | wc -l`if[ $procnum -eq 0];then
		/usr/bin/ssh  -f -C2qTnN -D 1080 your_name@your_domin -p 88-i /home/wenfeng/.ssh/id_rsa
	fi
	sleep 30
done

This still does not work, and the log shows Host key verification failed.

In the end, it was found that because the supervisor used the root account to run ssh, there would be a new knownhosts, so it would exit directly without entering yes to accept.

The following experiment shows that the fingerprint needs to be reconfirmed when running with sudo

sudo /usr/bin/ssh  -C2qTnN -D 1080 your_name@your_domin -p your_port -i /home/wenfeng/.ssh/id_rsa
The authenticity of host '[your_name]:88 ([your_ip]:88)' can't be established.
ECDSA key fingerprint is SHA256:M/7Vo2ZjnVVc********DgkZtIjrESKMIaj/rfryfDUmqc.
Are you sure you want to continueconnecting(yes/no)? yes

The solution is to log in with the root account first, or use the designated user function of supervisor in a similar process.

Recommended Posts

Use supervisor in ubuntu
Use of Anaconda in Ubuntu
How to use hanlp in ubuntu
Use disk quota in ubuntu multi-user
ubuntu zip/unzip use
Install mysql-pytho in Ubuntu
Nagios3 in ubuntu serve
How to use dpkg command in Ubuntu system
Use iptables under ubuntu
Use Ubuntu and windows system in virtual machine
Install python in Ubuntu
Install JDK in Ubuntu19.10
Introduction to the use of Hanlp in ubuntu
ubuntu 14.04 16.04 18.04 use Alibaba source
ubuntu supervisor manages uwsgi+nginx
Installation and use of SSH in Ubuntu environment
Installation and use of GDAL in Python under Ubuntu
How to use Putty to log in to ubuntu installed in VirtualBox
Install VMware Tools in Ubuntu 18.04
Use sublime tex under ubuntu
Use of mediawiki under ubuntu
Use virtualbox to deploy ubuntu
Core dump debugging in ubuntu
How to install Helm in Ubuntu
Happy installation of Jenkins in ubuntu
Use of Pandas in Python development
Common exceptions and solutions in the use and development of Ubuntu system
Use QQ under Ubuntu 13.10, suitable for 14.10
Use nohup command instructions in python
Detailed use of nmcli in CentOS8
How to install mysql in Ubuntu 14.04
Install and configure Docker in Ubuntu
Use of numpy in Python development
Ubuntu16.04 configuration OpenCV3.4.2 and basic use
Detailed explanation of the installation and use of SSH in the Ubuntu environment
Installation instructions for gitlab in Ubuntu
How to install mysql in Ubuntu 14.04
Ubuntu 20.04 use must install tool software
Linux basics (root privileges in Ubuntu)
Steps to upgrade Laravel 5.4 to 5.6 in Ubuntu 16.04
Use Ubuntu 16.04 for initial server setup
How to use SQLite in Python
FreeFileSync: Compare and synchronize files in Ubuntu
Use NTP for time synchronization in CentOS 7
Ubuntu16.04.5 installs full records in lvm mode
How to add swap partition in Ubuntu
How to easily compile openJDK in Ubuntu
Use mendeley to insert references under ubuntu
How to use and and or in Python
The locate file search command in Ubuntu16.04
Deploy django application in ubuntu through nginx+uwsgi
Set UTF-8 encoding for MySQL5.7 in Ubuntu 16.04
How to install cuda10.1 driver in Ubuntu
How to add users to Sudoers in Ubuntu
Configure Java development environment in Ubuntu20.04 LTS
About installing node environment in Ubuntu server
How to delete redundant kernels in Ubuntu
Ubuntu18.04 Server version installation and use (graphic)
Installation and deployment of Nginx in Ubuntu
How to delete redundant kernels in Ubuntu
How to use Samba server on Ubuntu 16.04