Macports 服务启动顺序

Macports 服务启动顺序

我在 Mac Os Catalina (10.15.7) 上使用 MacPorts 版本的 apache2 和 php82。服务在启动时加载,但我找不到以正确顺序启动它们的方法,即先启动 PHP,然后启动 apache。有时它们以正确的顺序启动,有时则不然,所以我必须卸载并加载 apache。有没有关于如何修复所需顺序的想法,以便 PHP 始终在 apache 之前启动?apache2 plist 如下:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>
<dict>
<key>Label</key><string>org.macports.apache2</string>
<key>ProgramArguments</key>
<array>
    <string>/opt/local/bin/daemondo</string>
    <string>--label=apache2</string>
    <string>--start-cmd</string>
    <string>/opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper</string>
    <string>start</string>
    <string>;</string>
    <string>--stop-cmd</string>
    <string>/opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper</string>
    <string>stop</string>
    <string>;</string>
    <string>--restart-cmd</string>
    <string>/opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper</string>
    <string>restart</string>
    <string>;</string>
    <string>--pid=none</string>
</array>
<key>Disabled</key><true/>
<key>KeepAlive</key><true/>
</dict>
</plist>

包装如下:

#!/bin/sh
#
# MacPorts generated daemondo support script
#

#
# Init
#
prefix=/opt/local

#
# Start
#
Start()
{
    [ -x /opt/local/sbin/apachectl ] && /opt/local/sbin/apachectl start > /dev/null
}

#
# Stop
#
Stop()
{
    [ -r /opt/local/var/run/apache2/httpd.pid ] && /opt/local/sbin/apachectl stop > /dev/null
}

#
# Restart
#
Restart()
{
    /opt/local/sbin/apachectl graceful > /dev/null
}

#
# Run
#
Run()
{
case $1 in
  start  ) Start   ;;
  stop   ) Stop    ;;
  restart) Restart ;;
  *      ) echo "$0: unknown argument: $1";;
esac
}

#
# Run a phase based on the selector
#
Run $1

php82 plist 是:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>
<dict>
<key>Label</key><string>org.macports.php82-fpm</string>
<key>ProgramArguments</key>
<array>
    <string>/opt/local/bin/daemondo</string>
    <string>--label=php82-fpm</string>
    <string>--start-cmd</string>
    <string>/opt/local/sbin/php-fpm82</string>
    <string>;</string>
    <string>--pid=exec</string>
</array>
<key>Disabled</key><false/>
<key>KeepAlive</key><true/>
</dict>
</plist>

没有 php 包装器。

相关内容