linux centos Supervisor installation configuration daemon process .netcore

 Scene: After using dotnet xx.dll can run when you have deployed .netcore program, but closed shell or cut-off time will be automatically disconnected, .netcore deployment program at this time can not be accessed at this time need to use the Supervisor

 Supervisor ( http://supervisord.org/ ) is developed with a client Python / server services, is a process management tool under Linux / Unix systems, Windows systems are not supported. It can easily monitor, start, stop, restart one or more processes. Supervisor with process management, when a process is killed unexpectedly, supervisort to monitor the process of death, it will automatically pull up again, it is convenient to do the process of automatic recovery functions, eliminating the need to write shell scripts to control.

1, install Python

yum install python-setuptools
easy_install supervisor

2, the new supervisor folder

mkdir /etc/supervisor

3, in the directory, the file generating supervisord.conf

echo_supervisord_conf > /etc/supervisor/supervisord.conf

4, New conf.d folder

mkdir /etc/supervisor/conf.d

At this point directory structure:

 

 

5, supervisord.conf edit files, add at the end of the file

[include]
files=conf.d/*.conf

 

 

 

6, add the file in conf.d in test.conf

document content:

[Program: testservice]; program name, the terminal needs to identify the control
Command = DOTNET test2.dll; command to run the program
Directory = / Home / Website / Test / ; directory command execution
autorestart is = to true ; quit unexpectedly restart automatically
stderr_logfile = / var / log / testservice.err.log; error log file
stdout_logfile = / var . / log / TestService OUT .log; output log file
Environment = ASPNETCORE_ENVIRONMENT = Production's; process environment variables
the User = root; the process execution user identity
StopSignal = the INT 
startsecs =. 1; automatic restart interval

7, designated supervisor profile

supervisord -c /etc/supervisor/supervisord.conf

8, Supervisor boot from the start

New File supervisord.service in the directory / usr / lib / systemd / system in

 

 

document content:

#supervisord.service

[Unit] 
Description=Supervisor daemon

[Service] 
Type=forking 
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown 
ExecReload=/usr/bin/supervisorctl reload 
KillMode=process 
Restart=on-failure 
RestartSec=42s

[Install] 
WantedBy=multi-user.target

9, validate the configuration

systemctl daemon-reload

  Restart Service supervisor
   $ supervisorctl reread
   if the restart is given when: 
   error: <class 'socket.error'>, [Errno 111] refused The Connection: File: Line /usr/lib64/python2.6/socket.py: 567
   then the service has not started, start you can:
   sudo supervisord -c /etc/supervisor/supervisord.conf
   sudo supervisorctl -c /etc/supervisor/supervisord.conf
   If you modify the /etc/supervisord.conf, you need to perform supervisorctl reload to reload the configuration file, otherwise it will not work.

 

10, a start-up service

systemctl enable supervisor.service

 11, verify whether the boot

systemctl is-enabled supervisord

 12, start the service

systemctl start supervisor.service

This completes

 

Reference article:

https://www.cnblogs.com/hobinly/p/7382038.html

https://my.oschina.net/lichaoqiang/blog/1861791

https://www.cnblogs.com/sundahua/p/9149692.html

https://blog.csdn.net/chivalrousli/article/details/60324140

 

Guess you like

Origin www.cnblogs.com/xiao-sheng/p/11627748.html