Recently in the study by linux deployment .netCore, carried out by the daemon service to run automatically Supervisor, and restart. Search for relevant information online through the initial configuration, out of a loss, some personal problems encountered are summarized as follows:
The first step: install Supervisor daemon through the command, I use centos system
yum install supervisor
After installation is complete, generated under / etc two files, a configuration file is supervisord.conf, a folder is supervisord.d, supervisord.conf profile view, the last line of add files = / etc / supervisor / conf.d / TestNetCore.conf, this can be customized, the project mainly includes user profiles
TestNetCore.conf file contents
[program:HelloWebApp]
command = dotnet HelloWebApp.dll command to be executed #
= Directory / Home / YXD / Workspace / publish # command execution directory
= = ASPNETCORE__ENVIRONMENT Production's Environment # environment variables
user = root user identity of the process of implementation #
stoplight = INT
= to true autostart # whether to automatically start
= to true autorestart is # restart automatically
=. 1 startsecs # automatic restart interval
= stderr_logfile / var / log / HelloWebApp.err.log # standard error log
= stdout_logfile / var / log / HelloWebApp.out.log # standard output log
Note: not every word back with a semicolon ";" I ignored copy this, put a semicolon after the automatic service process runs, prompted dotnet failure
Save and exit: wq
Supervisord re-run the command: systemctl restart supervisord, view the status command: systemctl status supervisord
Above the initial configuration is successful, the end of the probation service process configuration, then configure the boot from the start, restart the server downtime, service process runs automatically, without human intervention
1. Create a file in the specified directory supervisord.service
vi /usr/lib/systemd/system/supervisord.service open about editing content
[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
Save and exit
Execute the following command:
systemctl enable supervisord
prompt:
Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.
Verify to boot:
systemctl is-enabled supervisord
prompt:
enabled
Indicating setting finish!
At this point, create a supervisor daemon is completed.
Reference: https: //www.cnblogs.com/Hai--D/p/5820718.html