我正在尝试使用 systemd 来构建 Apache、PHP-FPM 和 MariaDB 服务的关闭和启动:
这些是文件/etc/systemd/system
夹中的其他配置文件:
# httpd.service
.include /usr/lib/systemd/system/httpd.service
[Unit]
After=mariadb.service php-fpm.service
Before=php-fpm.service
# php-fpm.service
.include /usr/lib/systemd/system/php-fpm.service
[Unit]
Before=mariadb.service
Run Code Online (Sandbox Code Playgroud)
我的意图是仅在 PHP-FPM 和 MariaDB 启动后才启动 Apache,并在停止 PHP-FPM 之前停止 Apache,在 MariaDB 之前停止 PHP-FPM。
但是,我在启动和关闭时都遇到错误:
12:42:09 systemd[1]: Found ordering cycle on php-fpm.service/stop
12:42:09 systemd[1]: Found dependency on mariadb.service/stop
12:42:09 systemd[1]: Found dependency on php-fpm.service/stop
12:42:09 systemd[1]: Job httpd.service/stop deleted to break ordering cycle starting with php-fpm.service/stop
12:42:09 systemd[1]: Stopping MariaDB database server...
12:42:12 systemd[1]: Stopped MariaDB database server. …
Run Code Online (Sandbox Code Playgroud)