I'm trying to use...
launchctl stop php-fpm (I renamed the label to something sane)
however, there seems to be issues. I suspect it has something to do with how it's all invoked and going against the expectations of launchd.
How can we start/stop/restart php-fpm?
Usage of launchctl stop is generally discouraged according to the launchctl manpage.
Likely the reason it isn't stopping the process is because our php-fpm.plist specifies that the process should be kept alive. It restarts itself right after you stop it.
You could set KeepAlive to false and then control it using your invocation above though.
yea, I tried that first thing, that doesn't fix it. Infact, I tried a ton of things, I can't get it to work at all. I think it has something to do with how it spawns new processes, etc.
You might be right. Processes that use daemon or emulate it are not to be used with launchd. I haven't looked into it, but I suspect this might be the cause.
If we change the php-fpm.conf file and set daemonize = no, it might do the trick.
daemonize = no
The other option is that PHP includes a init.d script for FPM. This request has been around for a while, and I was supposed to take care of it quite some time ago. It is trivial to implement (just copy the file from sapi/fpm/init.d.php-fpm to the destination), but I wasn't sure if it was appropriate (OS X design doesn't really lend itself to such scripts).
If people have an idea of where they want it (I'd assume /usr/local/sbin) and what to call it (php-fpm is taken, though I suppose we could use fpm), it'd only take a single line to implement.
sbin.install 'sapi/fpm/init.d.php-fpm' => 'fpm'
I personally don't feel that an init.d script is appropriate for this situation, so give the daemonize option a try.
We'd likely use something like php53-fpm or php54-fpm for the init.d script -which I am +1 on.
Ideally we remove the daemonize option and let launchd handle keeping the process up and running. What changes should we do to make this possible?
Oh, along the same lines, check this out... the plist fix here fixes the binding issue, which I was certainly getting every couple seconds in the logs...
A pull request would be nice...
I didn't realize that LaunchOnlyOnce wasn't a part of the original plist. Mine has always had it... must have added it sometime in the past.
Take a look at the plist branch on my fork. If it looks good I'll push it to master.
Seems legit. Please merge at your earliest convenience.
Sorry. Had to take care of finals first. Will merge tonight.
launchd - Launch FPM only once (see #370)
FPM: Include control script (see #370)
Done with 22c3465