This article is a mirror article of machine translation, please click here to jump to the original article.

View: 24325|Reply: 4

[.NET Core] Centos 7 .Net core background daemon supervisor tutorial

[Copy link]
Posted on 6/28/2018 1:54:48 PM | | | |
ASP.NET Core application release linux is normal to run in the shell. But once the shell is closed, the website will be closed, so to configure the daemon, use Supervisor, this article mainly records the configuration process and the problems encountered in the process

environment

Centos 7 x64-bit Tencent Cloud
Installed. Net core 2.1.301

Install the Supervisor



Configure the Supervisor

Create a directory under etc and assign permissions

Create a profile under the directory "/etc/supervisor"

Modify the configuration file

Add at the end of the file, pay attention to the beginning and end of the first and last spaces, and the top space
supervisord.conf (8.37 KB, Number of downloads: 4)

Create a dotnet core process profile in the directory "/etc/supervisor" and store the directory "conf.d"

Create a process profile

"itsvse" can be the name of the dotnet core entrance dll file, or it can be started casually, insert the content, note that there must be no spaces at the beginning and end, and the top space must be required:

itsvse.conf (294 Bytes, Number of downloads: 2)

[program:MyDotNetName] ; Display Name
command=/bin/bash -c "dotnet test.dll"  ; Run the command to start the dotnet process
directory=/root/app2/   ; MyDotNetNamedirectory
stderr_logfile=/var/log/MyDotNetName.error.log  ; Error log files
stdout_logfile=/var/log/MyDotNetName.stdout.log  ; Log files
environment=ASPNETCORE_ENVIRONMENT=Production  ; Process environment variables
user=root   ; Process execution user
autostart=true  ; autostart autorestart=true ; Whether to restart automatically
startsecs=3     ; Automatic restart interval


Create a supervisor self-start service


Editorial content:

supervisor.service (292 Bytes, Number of downloads: 2)


Make the configuration effective



Set the service to boot and start, that is, set enable



Start the service


Verify that the dotnet process starts

Use the command "ps -ef | grep dotnet" to see if dotnet is running

[root@VM_0_9_centos system]# ps -ef | grep dotnet
root     14924 14922  3 13:34 ?        00:00:01 dotnet test.dll
root     14981 14326  0 13:35 pts/6    00:00:00 grep --color=auto dotnet



supervisor remote management

Use the command "vim /etc/supervisor/supervisor/supervisord.conf" to modify the configuration file with the following settings

Restart the Supervisor




As shown below:







Previous:Solution to the error after closing the vim editor abnormally
Next:Implementation: Adding nginx to the systemctl service to auto-start under CentOS 7
 Landlord| Posted on 11/8/2018 10:34:56 AM |
If you want to update the dotnet website application, directly overwrite the dll file to the dll in the website directory

Then restart the Supervisor

systemctl restart  supervisor.service
 Landlord| Posted on 11/8/2018 10:49:38 AM |
supervisorctl -- control applications run by supervisord from the cmd line.

Usage: /usr/bin/supervisorctl [options] [action [arguments]]

Options:
-c/--configuration -- configuration file path (default /etc/supervisord.conf)
-h/--help -- print usage message and exit
-i/--interactive -- start an interactive shell after executing commands
-s/--serverurl URL -- URL on which supervisord server is listening
     (default "http://localhost:9001").
-u/--username -- username to use for authentication with server
-p/--password -- password to use for authentication with server
-r/--history-file -- keep a readline history (if readline is available)

action [arguments] -- see below

Actions are commands like "tail" or "stop".  If -i is specified or no action is
specified on the command line, a "shell" interpreting actions typed
interactively is started.  Use the action "help" to find out about available
actions.




 Landlord| Posted on 1/1/2024 7:49:17 PM |
Other process guards: Forever, Pm2, Supervisor
 Landlord| Posted on 3/21/2024 8:39:50 PM |
Start the Guardian ASP.NET Core app with PM2
https://www.itsvse.com/thread-10748-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com