1. Use
The daemon is used to keep a specified program (DLL) running at all times. Programs executed through the dotnet Run command in the command line terminal, after exiting the command line terminal, the program terminates automatically. After the daemon is added, the program can still execute in the background, even if the terminal exits. Can be used to perform timed tasks.
2. Installation (Environment: Ubuntu 16.04 dotnet 2.1.104)
sudo apt-get install supervisor (must be performed under root)
3. Modify the configuration file
Configuration file path:/ect/supervisor/conf.d/supervisord.conf
Modify the file directly
Gedit supervisord.conf
Increase:
1) Open the View process interface
[Inet_http_server]
port=127.0.0.1:7002
2) Add the daemon program
[Program:timetest]
Command=dotnet TimeTest.dll; instructions to be executed
Directory=/mnt/hgfs/projects/linux/surfacerunoff/timetest/timetest/bin/debug/netcoreapp2.0/publish;d LL's path
Autostart=true
Autorestart=true
Numprocs=1
process_name=timetests; name
3) Restart
Supervisord Reload
4) Access localhost:7002 (same as the port in the configuration file) to view all programs that are currently running
Complete example of a configuration file:
; Supervisor Config file
[Unix_http_server]
File=/var/run/supervisor.sock; (The path to the socket file)
chmod=0700; SOCKEF file Mode (default 0700) _
[Inet_http_server]
port=127.0.0.1:7002
[Supervisord]
Logfile=/var/log/supervisor/supervisord.log; (Main log file;default $CWD/supervisord.log)
Pidfile=/var/run/supervisord.pid; (Supervisord Pidfile;default Supervisord.pid)
Childlogdir=/var/log/supervisor; (' AUTO ' child log dir, default $TEMP)
; The below section must remain in the config file for RPC
; (Supervisorctl/web interface) to work, additional interfaces
; Added by defining them in separate rpcinterface:sections
[Rpcinterface:supervisor]
Supervisor.rpcinterface_factory = Supervisor.rpcinterface:make_main_rpcinterface
[Supervisorctl]
Serverurl=unix:///var/run/supervisor.sock; Use a unix://URL for a UNIX socket
; The [include] section can just contain the "files" setting. This
; Setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames is
; interpreted as relative to the this file. Included Files *cannot*
; Include files themselves.
[Program:timetest]
Command=dotnet TimeTest.dll
Directory=/mnt/hgfs/projects/linux/surfacerunoff/timetest/timetest/bin/debug/netcoreapp2.0/publish
Autostart=true
Autorestart=true
Numprocs=1
Process_name=timetests
[include]
Files =/etc/supervisor/conf.d/*.conf
4. Reference:
Https://www.cnblogs.com/savorboard/p/dotnetcore-supervisor.html (there seems to be a problem with the configuration file setting method, it can not be viewed through the browser after adding, it may be a version issue, no further discussion)
Https://www.cnblogs.com/dingsblog/p/7040680.html (later press this post to complete the configuration file modification)
Add daemons via Supervisor in Ubuntu