SYSTEMD is a Linux system tool used to launch daemons and has become the standard configuration for most distributions. You can systemctl --version
view the version you are using by command
Common commands
# 立即启动一个服务$ sudo systemctl start apache.service# 立即停止一个服务$ sudo systemctl stop apache.service# 重启一个服务$ sudo systemctl restart apache.service# 杀死一个服务的所有子进程$ sudo systemctl kill apache.service# 重新加载一个服务的配置文件$ sudo systemctl reload apache.service# 重载所有修改过的配置文件$ sudo systemctl daemon-reload# 显示某个 Unit 的所有底层参数$ systemctl show httpd.service
Supervisor
Supervisor is a process management program written in Python that can be used not only to manage processes, but also to boot. It has, but is not limited to, some of the following features:
After restarting the machine, it is capable of self-booting.
Usually there is a convenient way to view the process.
There is a convenient way to restart the process.
Configuration methods do not record here, but note that the default configuration file will be some of the supervisor generated important files in the /tmp
directory, the operating system may delete these files, resulting in the supervisorctl
command because they could not find these previously placed in /tmp
Files and cannot operate the supervisor process that has already been started.
Method
In order to be able to automatically start supervisor after the machine starts, the supervisor process needs to be configured into SYSTEMD,
Steps:
- Enter the directory
/usr/lib/systemd/system/
and add files to supervisord.service
enable the machine to start Supervisor, file content
# Supervisord service for SYSTEMD (CentOS 7.0+) # by Et-cs (Https://github.com/ET-CS) [unit] description=supervisor daemon[service] type=forkingexecstart=/usr/bin/supervisord-c/etc/ Supervisord.confexecstop=/usr/bin/supervisorctl $OPTIONS Shutdownexecreload=/usr/bin/supervisorctl $OPTIONS reload< Span class= "hljs-attr" >killmode=processrestart=on-failure< Span class= "hljs-attr" >restartsec=42s[Install]wantedby=multi-user.target
Activating the boot command
enable supervisord.service
Start the Supervisor process
start supervisord.service
Close the Supervisor process
stop supervisord.service
If you modify the Supervisor.service file, you can reload the configuration file by using the reload command
systemctl reload supervisord.service
Check
Commands allow you to ps
see whether supervisor is started, and you can see whether the supervisor managed process is started.
Booting a program from the CentOS boot