在启动Mac OS X上运行Jetty服务

时间:2014-02-23 11:58:18

标签: macos jetty plist launchd

每当iMac启动时,我都会尝试启动Jetty网络服务器。我写了以下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>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.posios.jetty</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/cvv/Documents/Jetty7/bin/jetty.sh</string>
        <string>start</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

然而,似乎服务开始但不知何故以循环结束。我猜这是因为每隔几秒就会在Jetty的logs文件夹中生成一个新的日志文件。在日志中我可以看到服务正在启动并且正在部署不同的WAR文件,但后来我看到contexthandler已停止。

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

有没有人有这方面的经验,或者我是否以错误的方式启动服务?如果我通过执行相同的命令“/Users/cvv/Documents/Jetty7/bin/jetty.sh start”手动启动服务,一切都会启动。在日志中,我可以清楚地看到代码的开始正在被执行,但是突然间它被杀死了。

我使用Jetty 7.6.14运行Mac OS X 10.9.1。

非常感谢任何帮助。

--- ---编辑 我通过将其从LaunchDaemon更改为LaunchAgent来确保它比其他服务更晚启动。究竟是什么原因,我不知道,但我想我会分享这些信息。不管怎样,谢谢。

0 个答案:

没有答案