Troubleshoot launchd/launchctl issue where application won’t load

launchd

I'm trying to load a LaunchAgent in ~/Library/LaunchAgents and although, from command line, it "appears" to load. However, if I try to load it again it says it's "already loaded".

But a process for the application isn't running. ps -e | grep mongo shows nothing (well it shows this grep command).

Anyone know how to troubleshoot these kinds of problems?

Only thing I can find is in /var/log/system.log:

Feb  9 13:15:26 imac com.apple.launchd.peruser.502[130] (homebrew.mxcl.mongodb): Ignored this key: UserName

I'm assuming it's ignoring the UserName because it's being launched from my User directory: ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist. And as per docs this is to be expected.

I can launch the application just fine from Terminal:

/usr/local/bin/mongod

Here's the LaunchAgent 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>homebrew.mxcl.mongodb</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/bin/mongod</string>
    <string>run</string>
    <string>--config</string>
    <string>/usr/local/etc/mongod.conf</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <false/>
  <key>UserName</key>
  <string>meltemi</string>
  <key>WorkingDirectory</key>
  <string>/usr/local</string>
  <key>StandardErrorPath</key>
  <string>/usr/local/var/log/mongodb/output.log</string>
  <key>StandardOutPath</key>
  <string>/usr/local/var/log/mongodb/output.log</string>
</dict>
</plist>

Best Answer

Got it solved. Will leave this question here…in case someone else has similar issue…and in hopes that someone can offer some good ideas for troubleshooting launchd/launchctl in the future.

My problem was I didn't have my mongod.conf file in the right place. As per plist directive launchctl (or is it launchd?) was looking for /usr/local/etc/mongod.conf but couldn't find it, so, it "loaded" mongod but the app never actually started...and there were no errors to that effect…that I could find.