2
I have been troubleshooting this issue for a while now. Consulted the web, several stackexchange platforms and discussion forums. Here is my problem description:
Usecase:
I have naviserver installed on a mac os x el capitan 10.11.6
Instead of calling
/usr/local/ns/bin/nsd -f -u nsadmin -g nsadmin -t /usr/local/ns/conf/nsd-config.tcl
to start the server and a kill command to stop the server I would like to manage it through a LaunchDaemon.
Problem Description:
I can successfully start a LaunchDaemon through launchctl
. However when looking at the launchctl
list it lists the plist without a PID. I therefore need to stop the service manually via kill
- instead I would like to be able to stop the service with launchctl stop
.
Question in essence:
Why doesn't launchctl list the PID of it's successfully started LaunchDaemon?
What I have tried so far
- Changing the plist file, minimizing parameters, no KeepAlive, no OnDemand, include Program parameter
- Changing ownerships admin:wheel nsadmin:nsadmin admin:root
- Running as LaunchAgent via /Library/LaunchAgents directory
Here is what I have done:
I have the following plist under /Library/LaunchDaemons/org.naviserver.dev01.plist
<?xml version=“1.0” encoding=“UTF-8”?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=“1.0”>
<dict>
<key>Label</key>
<string>org.naviserver.dev01</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/ns/bin/nsd</string>
<string>-u</string>
<string>nsadmin</string>
<string>-g</string>
<string>nsadmin</string>
<string>-t</string>
<string>/usr/local/ns/conf/nsd-config.tcl</string>
</array>
<key>StandardOutPath</key>
<string>/usr/local/var/log/naviserver_daemon.log</string>
<key>StandardErrorPath</key>
<string>/usr/local/var/log/naviserver_daemon.log</string>
</dict>
</plist>
The following privileges and ownerships apply
-rw-r--r-- 1 root admin 857 Aug 11 15:03 org.naviserver.dev01.plist
Starting the service works
sudo launchctl load org.naviserver.dev01.plist
sudo launchctl start org.naviserver.dev01
However the launchctl list does not show the service’s PID
sudo launchctl list | grep naviserver
- 0 org.naviserver.dev01
I can find the running process via
ps -ax | grep nsd
Currently I am always manually restarting the server through a kill
via the PID, which isn’t nice. I’d like to manage this through launchctl
which works with starting the process but not with stopping it again.
Has anyone else run into this problem and is there anything obviously wrong with my approach, which I can change to solve this issue?
Oh my! Thank you very much for pointing this out - it solved the issue. Thanks! – Mike F – 2016-08-16T06:39:25.757