title: OSX launchd plist for node forever process
body: <p>I am trying to write a launchd.plist file for my node server.  I am using forever to run my node server.  I would like the server to start on boot.  I would also like to wait for the mongodb launchd plist to run first.</p>
  
  <p>I installed mongobb using homebrew and it came with a launchd.plist already.  I have executed the following:</p>
  
  <pre><code>$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
  </code></pre>
  
  <p>plist for mongodb is:</p>
  
  
  
  <pre><code>&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;homebrew.mxcl.mongodb&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;/usr/local/opt/mongodb/mongod&lt;/string&gt;
      &lt;string&gt;run&lt;/string&gt;
      &lt;string&gt;--config&lt;/string&gt;
      &lt;string&gt;/usr/local/etc/mongod.conf&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;WorkingDirectory&lt;/key&gt;
    &lt;string&gt;/usr/local&lt;/string&gt;
    &lt;key&gt;StandardErrorPath&lt;/key&gt;
    &lt;string&gt;/usr/local/var/log/mongodb/output.log&lt;/string&gt;
    &lt;key&gt;StandardOutPath&lt;/key&gt;
    &lt;string&gt;/usr/local/var/log/mongodb/output.log&lt;/string&gt;
    &lt;key&gt;HardResourceLimits&lt;/key&gt;
    &lt;dict&gt;
      &lt;key&gt;NumberOfFiles&lt;/key&gt;
      &lt;integer&gt;1024&lt;/integer&gt;
    &lt;/dict&gt;
    &lt;key&gt;SoftResourceLimits&lt;/key&gt;
    &lt;dict&gt;
      &lt;key&gt;NumberOfFiles&lt;/key&gt;
      &lt;integer&gt;1024&lt;/integer&gt;
    &lt;/dict&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>If I shutdown the computer and restart mongodb fires up as it should.</p>
  
  <p>However my node server is not starting.  Any ideas?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
      &lt;dict&gt;
          &lt;key&gt;KeepAlive&lt;/key&gt;
          &lt;dict&gt;
              &lt;key&gt;SuccessfulExit&lt;/key&gt;
              &lt;false/&gt;
          &lt;/dict&gt;
          &lt;key&gt;Label&lt;/key&gt;
          &lt;string&gt;com.test.app&lt;/string&gt;
          &lt;key&gt;ProgramArguments&lt;/key&gt;
          &lt;array&gt;
              &lt;string&gt;/usr/local/bin/forever&lt;/string&gt;
              &lt;string&gt;-a&lt;/string&gt;
              &lt;string&gt;-l&lt;/string&gt;
              &lt;string&gt;/var/log/app/app.log&lt;/string&gt;
              &lt;string&gt;-e&lt;/string&gt;
              &lt;string&gt;/var/log/app/app_error.log&lt;/string&gt;
              &lt;string&gt;/data/server/app.js&lt;/string&gt;
          &lt;/array&gt;
          &lt;key&gt;RunAtLoad&lt;/key&gt;
          &lt;true/&gt;
          &lt;key&gt;StartInterval&lt;/key&gt;
          &lt;integer&gt;3600&lt;/integer&gt;
      &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>writing to log file and I see this:</p>
  
  <blockquote>
    <p>env: node: No such file or directory</p>
  </blockquote>
  
  <p>I think this means that the node binary cannot be found.  I can echo $PATH and /usr/local/bin is in my path.  I can start node from the terminal.  Ideas?</p>