Launchctl won’t load php-fpm with this LaunchAgent

launchctllaunchdloggingmac-osxphp-fpm

I'm trying to start php-fpm with launchctl.

Running directly from the command line is no problem:

$ /usr/sbin/php-fpm -p /Users/dmitry -e

Here's the contents of /Users/dmitry/Library/LaunchAgents/dminkovsky.php-fpm.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>dminkovsky.php-fpm</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/sbin/php-fpm</string>
      <string>-p</string>
      <string>/Users/dmitry/var</string>
      <string>-e</string>
    </array>
    <key>EnableGlobbing</key>
    <true/>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
  </dict>
</plist>

For some reason the process doesn't start with this .plist. Nothing is logged, either, so I don't know why. In /var/log/system.log, I have:

Nov 18 08:38:30 airosol com.apple.launchd.peruser.503[285] (dminkovsky.php-fpm[19833]): Exited with code: 78
Nov 18 08:38:30 airosol com.apple.launchd.peruser.503[285] (dminkovsky.php-fpm): Throttling respawn: Will start in 10 seconds

I don't know where to take it from here though.

Most oddly, this .plist used to work before upgrading to Mavericks.

Thank you!

Best Answer

php-fpm's error code 78 seems to correspond to EX_CONFIG (see one of the messages here), indicating some sort of configuration error. It's possible the error is preventing php-fpm from using any of your configured settings, including logging settings. You may be able to get more information by capturing the stdin and stdout from the php-fpm process by adding something like this to your .plist:

<key>StandardOutPath</key>
<string>/var/log/php-fhm-out.log</string>
<key> StandardErrorPath</key>
<string>/var/log/php-fhm-err.log</string>