title: Run Jetty service at startup Mac OS X
body: <p>I am trying to launch a Jetty webserver whenever the iMac boots. I have written the following plist to start the service:</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;true/&gt;
      &lt;key&gt;Label&lt;/key&gt;
      &lt;string&gt;com.posios.jetty&lt;/string&gt;
      &lt;key&gt;ProgramArguments&lt;/key&gt;
      &lt;array&gt;
          &lt;string&gt;/Users/cvv/Documents/Jetty7/bin/jetty.sh&lt;/string&gt;
          &lt;string&gt;start&lt;/string&gt;
      &lt;/array&gt;
      &lt;key&gt;RunAtLoad&lt;/key&gt;
      &lt;true/&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>However, it seems the service starts but somehow ends in a loop. I am guessing this because every couple of seconds a new log file is generated in the logs folder of Jetty. In the logs I can see that the service is starting and the different WAR files are being deployed but then I see contexthandler stopped.</p>
  
  <pre><code>2014-02-23 12:53:23.643:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/Registration,file:/private/tmp/jetty-0.0.0.0-8080-Registration.war-_Registration-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/Registration.war
  2014-02-23 12:53:23.649:INFO:oejd.DeploymentManager:Deployable added: /Users/cvv/Documents/Jetty7/webapps/management1.war
  2014-02-23 12:53:23.652:INFO:oejw.WebInfConfiguration:Extract jar:file:/Users/cvv/Documents/Jetty7/webapps/management1.war!/ to /private/tmp/jetty-0.0.0.0-8080-management1.war-_management1-any-/webapp
  2014-02-23 12:53:25.267:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/management1,file:/private/tmp/jetty-0.0.0.0-8080-management1.war-_management1-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/management1.war
  2014-02-23 12:53:25.299:INFO:oejd.DeploymentManager:Deployable added: /Users/cvv/Documents/Jetty7/webapps/spdy.war
  2014-02-23 12:53:25.307:INFO:oejw.WebInfConfiguration:Extract jar:file:/Users/cvv/Documents/Jetty7/webapps/spdy.war!/ to /private/tmp/jetty-0.0.0.0-8080-spdy.war-_spdy-any-/webapp
  2014-02-23 12:53:25.630:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/spdy,file:/private/tmp/jetty-0.0.0.0-8080-spdy.war-_spdy-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/spdy.war
  2014-02-23 12:53:25.635:INFO:oejdp.ScanningAppProvider:Deployment monitor /Users/cvv/Documents/Jetty7/contexts at interval 1
  2014-02-23 12:53:25.637:INFO:oejd.DeploymentManager:Deployable added: /Users/cvv/Documents/Jetty7/contexts/posimages.xml
  2014-02-23 12:53:25.647:INFO:oejsh.ContextHandler:started o.e.j.s.h.ContextHandler{/posimages,file:/Users/cvv/posios/users/}
  2014-02-23 12:53:25.648:INFO:oejd.DeploymentManager:Deployable added: /Users/cvv/Documents/Jetty7/contexts/javadoc.xml
  2014-02-23 12:53:25.675:INFO:oejsh.ContextHandler:started o.e.j.s.h.ContextHandler{/javadoc,file:/Users/cvv/Documents/Jetty7/javadoc/}
  2014-02-23 12:53:25.680:INFO:oejd.DeploymentManager:Deployable added: /Users/cvv/Documents/Jetty7/contexts/test.xml
  2014-02-23 12:53:25.729:INFO:oejw.WebInfConfiguration:Extract jar:file:/Users/cvv/Documents/Jetty7/webapps/test.war!/ to /private/tmp/jetty-0.0.0.0-8080-test.war-_-any-/webapp
  2014-02-23 12:53:26.390:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/private/tmp/jetty-0.0.0.0-8080-test.war-_-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/test.war
  2014-02-23 12:53:26.601:INFO:oejs.TransparentProxy:TransparentProxy @ /javadoc-proxy to http://download.eclipse.org/jetty/stable-7/apidocs
  2014-02-23 12:53:26.630:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
  2014-02-23 12:53:28.866:INFO:oejs.Server:Graceful shutdown SelectChannelConnector@0.0.0.0:8080
  2014-02-23 12:53:28.867:INFO:oejs.Server:Graceful shutdown o.e.j.w.WebAppContext{/partner,file:/private/tmp/jetty-0.0.0.0-8080-partner.war-_partner-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/partner.war
  2014-02-23 12:53:28.868:INFO:oejs.Server:Graceful shutdown o.e.j.w.WebAppContext{/PosServer,file:/private/tmp/jetty-0.0.0.0-8080-PosServer.war-_PosServer-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/PosServer.war
  2014-02-23 12:53:28.869:INFO:oejs.Server:Graceful shutdown o.e.j.w.WebAppContext{/Registration,file:/private/tmp/jetty-0.0.0.0-8080-Registration.war-_Registration-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/Registration.war
  2014-02-23 12:53:28.871:INFO:oejs.Server:Graceful shutdown o.e.j.w.WebAppContext{/management1,file:/private/tmp/jetty-0.0.0.0-8080-management1.war-_management1-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/management1.war
  2014-02-23 12:53:28.872:INFO:oejs.Server:Graceful shutdown o.e.j.w.WebAppContext{/spdy,file:/private/tmp/jetty-0.0.0.0-8080-spdy.war-_spdy-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/spdy.war
  2014-02-23 12:53:28.874:INFO:oejs.Server:Graceful shutdown o.e.j.s.h.ContextHandler{/posimages,file:/Users/cvv/posios/users/}
  2014-02-23 12:53:28.874:INFO:oejs.Server:Graceful shutdown o.e.j.s.h.ContextHandler{/javadoc,file:/Users/cvv/Documents/Jetty7/javadoc/}
  2014-02-23 12:53:28.874:INFO:oejs.Server:Graceful shutdown o.e.j.w.WebAppContext{/,file:/private/tmp/jetty-0.0.0.0-8080-test.war-_-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/test.war
  2014-02-23 12:53:29.977:INFO:oejsl.ELContextCleaner:javax.el.BeanELResolver purged
  2014-02-23 12:53:29.977:INFO:oejsh.ContextHandler:stopped o.e.j.w.WebAppContext{/,file:/private/tmp/jetty-0.0.0.0-8080-test.war-_-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/test.war
  2014-02-23 12:53:29.988:INFO:oejsh.ContextHandler:stopped o.e.j.s.h.ContextHandler{/javadoc,file:/Users/cvv/Documents/Jetty7/javadoc/}
  2014-02-23 12:53:29.988:INFO:oejsh.ContextHandler:stopped o.e.j.s.h.ContextHandler{/posimages,file:/Users/cvv/posios/users/}
  2014-02-23 12:53:29.999:INFO:oejsl.ELContextCleaner:javax.el.BeanELResolver purged
  2014-02-23 12:53:29.999:INFO:oejsh.ContextHandler:stopped o.e.j.w.WebAppContext{/spdy,file:/private/tmp/jetty-0.0.0.0-8080-spdy.war-_spdy-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/spdy.war
  2014-02-23 12:53:30.009:INFO:oejsl.ELContextCleaner:javax.el.BeanELResolver purged
  2014-02-23 12:53:30.009:INFO:oejsh.ContextHandler:stopped o.e.j.w.WebAppContext{/management1,file:/private/tmp/jetty-0.0.0.0-8080-management1.war-_management1-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/management1.war
  2014-02-23 12:53:30.103:INFO:oejsl.ELContextCleaner:javax.el.BeanELResolver purged
  2014-02-23 12:53:30.103:INFO:oejsh.ContextHandler:stopped o.e.j.w.WebAppContext{/Registration,file:/private/tmp/jetty-0.0.0.0-8080-Registration.war-_Registration-any-/webapp/},/Users/cvv/Documents/Jetty7/webapps/Registration.war
  </code></pre>
  
  <p>Does anyone have experience with this, or am I starting the service the wrong way? If I start the service manually by executing the same command "/Users/cvv/Documents/Jetty7/bin/jetty.sh start" everything starts up. In the log I can clearly see the beginning of the code is being executed, however all of the sudden it is being killed.</p>
  
  <p>I am running Mac OS X 10.9.1 with Jetty 7.6.14.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>---Edit---
  I got working by changing it form a LaunchDaemon to a LaunchAgent making sure it is launched later than the other services. What the precise reason is, I don't know, but I thought I'd share the information. Thanks anyway.</p>