Scenario: After deploying the .netcore program, it can run after using dotnet xx.dll, but it will be automatically disconnected after closing the shell or after the interval time. At this time, the deployed .netcore program cannot be accessed. Supervisor is used
Supervisor (http://supervisord.org/) is a client/server service developed in Python. It is a process management tool under Linux/Unix systems and does not support Windows systems. It can easily monitor, start, stop, and restart one or more processes. When a process is managed by Supervisor, when a process is killed accidentally, supervisort will automatically re-pull it up after it detects that the process is dead. It is very convenient to achieve the function of automatic process recovery, no longer need to write shell scripts to control it.
1, install Python
yum install python-setuptools
easy_install supervisor
2, create a new supervisor folder
mkdir /etc/supervisor
3. In this directory, generate supervisord.conf file
echo_supervisord_conf> /etc/supervisor/supervisord.conf
< /div>
4. Create a new conf.d folder
mkdir /etc/supervisor/conf.d
This The directory structure at the time:
p>
5. Edit the supervisord.conf file and add it at the end of the file
[include]
files=conf.d/*.conf< /pre>
6. Add the file test.conf in conf.d
File content:
[program:testservice]; program name, identification required for terminal control
command=dotnet test2.dll; command to run the program
directory=/home/website/test/; The directory where the command is executed
autorestart=true; Whether the program exits unexpectedly will automatically restart
stderr_logfile=/var/log/testservice.err.log; error Log file
stdout_logfile=/var/log/testservice.out .log; output log file
environment=ASPNETCORE_ENVIRONMENT=Production; Process environment variables
user=root; The user identity of the process execution
stopsignal=INT
startsecs=1; Automatic restart interval
7. Specify supervisor configuration file
supervisord -c /etc/supervisor/supervisord.conf
8, Supervisor starts automatically after booting
Create a new file in the directory /usr/lib/systemd/system File supervisord.service
File 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. Make the configuration effective
systemctl daemon-reload
Restart the supervisor service
$ supervisorctl reread
If an error is reported when restarting:
Error:
It means that the service has not been started yet, just start it first:
sudo supervisord -c /etc/supervisor/supervisord.conf
sudo supervisorctl -c /etc/supervisor/supervisord.conf
If you modify /etc/supervisord.conf, you need to execute supervisorctl reload to reload the configuration file, otherwise it will not take effect.
10. Set the service to start up
systemctl enable supervisor.service
11. Verify whether it is booting up
systemctl is-enabled supervisord
< /div>
12. Start the service
systemctl start supervisor.service
This is complete
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
yum install python-setuptools
easy_install supervisor
mkdir /etc/supervisor
echo_supervisord_conf> /etc/supervisor/ supervisord.conf
mkdir /etc/supervisor/conf.d
[include]
files=conf.d/*.conf< /pre>[program:testservice]; program name, the identification required for terminal control
command=dotnet test2.dll; command to run the program
directory=/home/website/test/; The directory where the command is executed
autorestart=true; Whether the program exits unexpectedly will automatically restart
stderr_logfile=/var/log/testservice.err.log; error Log file
stdout_logfile=/var/log/testservice.out .log; output log file
environment=ASPNETCORE_ENVIRONMENT=Production; Process environment variables
user=root; The user identity of the process execution
stopsignal=INT
startsecs=1; Automatic restart intervalsupervisord -c /etc/supervisor/supervisord.conf#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.targetsystemctl daemon-reloadsystemctl enable supervisor .servicesystemctl is-enabled supervisord
systemctl start supervisor.service
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5074 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC