Jetty 7是否支持使用Java Service Wrapper作为服务运行? 我现在有什么选择?将Jetty 7作为Windows服务运行
回答
@glb,感谢您指出apache commons-daemon Procrun。
它在Windows 7 64位上对我很有帮助,下面是我设置它的方法。
欲了解更多信息请参阅
- procrun页面每条链路从@glb
- 码头帮助屏幕> Java的罐子start.jar --help
REM 1. Open command prompt as Administrator
mkdir C:\java\apache-commons-daemon
REM 2. Download commons-daemon binaries for windows to directory above from
REM http://www.apache.org/dist/commons/daemon/binaries/windows/commons-daemon-1.0.15-bin-windows.zip
REM 3. unzip which will create C:\java\apache-commons-daemon\commons-daemon-1.0.5-bin-windows
mkdir C:\java\jetty
REM 4. Download jetty to directory above from
REM http://download.eclipse.org/jetty/7.4.2.v20110526/dist/jetty-distribution-7.4.2.v20110526.zip
REM 5. install/unzip which will create C:\java\jetty\jetty-distribution-7.4.2.v20110526
REM 6. Verify that jetty can be started
cd C:\java\jetty\jetty-distribution-7.4.2.v20110526
java -jar start.jar
REM Look for any obvious errors on the console
REM Open a browser at http://localhost:8080/
REM You should be presented with the Jetty Start Page,
REM and be able to execute the Hello World Servlet
REM OK, that's enough,
REM come back to the command prompt and ctrl-C to stop the jetty server
REM 7. Copy and rename commons-daemon binaries into the JETTY_HOME directory structure
REM Note that the GUI manager is copied to JETTY_HOME,
REM and the service exe is copied to JETTY_HOME\bin
REM Note that both binaries get the same target name,
REM but are placed in different directories
REM This is just makes it easier to launch the GUI manager
REM by not having to provide command line arguments
REM Note that I have selected the amd64\prunsrv.exe as the service exe,
REM I am running on Windows 7 64 bit Intel i7 Xeon
cd C:\java\jetty\jetty-distribution-7.4.2.v20110526
copy \java\apache-commons-daemon\commons-daemon-1.0.5-bin-windows\prunmgr.exe .\JettyService.exe
copy \java\apache-commons-daemon\commons-daemon-1.0.5-bin-windows\amd64\prunsrv.exe .\bin\JettyService.exe
REM 8. Time to install the service
bin\JettyService //IS//JettyService --DisplayName="Jetty Service" --Install=C:\java\jetty\jetty-distribution-7.4.2.v20110526\bin\JettyService.exe --LogPath=C:\java\jetty\jetty-distribution-7.4.2.v20110526\logs --LogLevel=Debug --StdOutput=auto --StdError=auto --StartMode=Java --StopMode=Java --Jvm=auto ++JvmOptions=-Djetty.home=C:\java\jetty\jetty-distribution-7.4.2.v20110526 ++JvmOptions=-DSTOP.PORT=8087 ++JvmOptions=-DSTOP.KEY=downB0y ++JvmOptions=-Djetty.logs=C:\java\jetty\jetty-distribution-7.4.2.v20110526\logs ++JvmOptions=-Dorg.eclipse.jetty.util.log.SOURCE=true ++JvmOptions=-XX:MaxPermSize=128M ++JvmOptions=-XX:+CMSClassUnloadingEnabled ++JvmOptions=-XX:+CMSPermGenSweepingEnabled --Classpath=C:\java\jetty\jetty-distribution-7.4.2.v20110526\start.jar --StartClass=org.eclipse.jetty.start.Main ++StartParams=OPTIONS=All ++StartParams=C:\java\jetty\jetty-distribution-7.4.2.v20110526\etc\jetty.xml ++StartParams=C:\java\jetty\jetty-distribution-7.4.2.v20110526\etc\jetty-deploy.xml ++StartParams=C:\java\jetty\jetty-distribution-7.4.2.v20110526\etc\jetty-webapps.xml ++StartParams=C:\java\jetty\jetty-distribution-7.4.2.v20110526\etc\jetty-contexts.xml ++StartParams=C:\java\jetty\jetty-distribution-7.4.2.v20110526\etc\jetty-testrealm.xml --StopClass=org.eclipse.jetty.start.Main ++StopParams=--stop
REM 9. Test that the service starts at the command prompt
bin\JettyService //TS
REM 10. To delete the service uncomment the line below
REM bin\JettyService //DS
REM 11. Now launch the GUI manager to check the parameter settings
JettyService.exe
REM You can use the GUI to start and stop the service, and to change the settings
REM If you want the GUI exe to have a different name to the service exe,
REM then close the GUI and uncomment and run the line below
REM ren JettyService.exe JettyServiceMgr.exe
REM To launch the renamed GUI uncomment and run the line below
REM JettyServiceMgr.exe //ES//JettyService
完成!
在Java Service Wrapper最新的稳定版本(3.4.1 JSW)有集成的WrapperJarApp方法:
这是我配置的一部分:
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperJarApp
wrapper.java.classpath.1=%WRAPPER_HOME%/lib/*.jar
wrapper.java.classpath.2=%JETTY_HOME%/lib/*.jar
wrapper.java.classpath.3=%JETTY_HOME%/start.jar
wrapper.java.library.path.1=%WRAPPER_HOME%/lib
wrapper.app.parameter.1=%JETTY_HOME%/start.jar
wrapper.app.parameter.2=%JETTY_HOME%/etc/jetty.xml
# other config params as needed
在我最初的测试中,如果JSW是从'%JETTY_HOME%'启动的,那么Jetty显得效果最好。将JSW配置,jar和DLL放入Jetty安装目录中)。这样,如果Jetty查找相对于当前路径的配置设置,服务将从预期的位置运行。 – mckamey 2010-12-07 18:36:54
采取从Apache下议院看看Procrun 。您需要浏览本机二进制文件下载区以获取Windows二进制文件。
您可以从:http://svn.codehaus.org/jetty/jetty/branches/jetty-7/jetty-win32/获取src并自行构建。
但我手动安装包装作为任何“标准”包装安装。
接过原始码头-Service.conf文件和改变:
wrapper.java.mainclass = org.mortbay.jetty.win32service.JettyServiceWrapperListener 到 wrapper.java.mainclass = org.tanukisoftware.wrapper。 WrapperSimpleApp
并补充...
wrapper.app.parameter.1 = org.eclipse.jetty.start.Main < - 主类 wrapper.app.parameter.2 = .. /等/码头。 xml wrapper.app.parameter.x = ../etc /jetty-x.xml < - 您希望包括的任何其他配置文件... wrapper.app.parameter.y = ../etc/jetty-y.xml
似乎开始很好,它似乎关机也优雅。
我有一个问题运行@ crowne的代码来安装服务(我运行Jetty 8.1.0)。只需要将-StartMode=Java --StopMode=Java
更改为-StartMode=jvm --StopMode=jvm
并删除++JvmOptions=-XX:+CMSPermGenSweepingEnabled
即可。
之后,我在码头/ bin文件夹中创建一个create_jetty_service.bat并从那里运行该文件:
set jetty_home = C:\java\jetty\jetty-hightide-8.1.0.v20120127
JettyService //IS//JettyService --DisplayName="Jetty Service"^
--Install=%jetty_home%\bin\JettyService.exe^
--LogPath=%jetty_home%\logs^
--LogLevel=Debug --StdOutput=auto --StdError=auto --StartMode=jvm --StopMode=jvm --Jvm=auto^
++JvmOptions=-Djetty.home=%jetty_home%^
++JvmOptions=-DSTOP.PORT=8087^
++JvmOptions=-DSTOP.KEY=downB0y^
++JvmOptions=-Djetty.logs=%jetty_home%\logs^
++JvmOptions=-Dorg.eclipse.jetty.util.log.SOURCE=true^
++JvmOptions=-XX:MaxPermSize=256M^
++JvmOptions=-XX:+CMSClassUnloadingEnabled^
--Classpath=%jetty_home%\start.jar^
--StartClass=org.eclipse.jetty.start.Main^
++StartParams=OPTIONS=All^
++StartParams=%jetty_home%\etc\jetty.xml^
++StartParams=%jetty_home%\etc\jetty-deploy.xml^
++StartParams=%jetty_home%\etc\jetty-webapps.xml^
++StartParams=%jetty_home%\etc\jetty-contexts.xml^
++StartParams=%jetty_home%\etc\jetty-testrealm.xml^
--StopClass=org.eclipse.jetty.start.Main ++StopParams=--stop
记住运行CMD.EXE以管理员身份命令生效。
您可以作为Windows服务运行Jetty可用于解包。
Jetty Windows Service一体化软件包也被分发。
如果你是在一个位锁定的环境和需要留内的微软提供的工具集,然后srvany
,instsrv
和sc
是你的朋友。不幸的是,它通常包括进行注册表编辑。好的是它非常灵活。
这是我最近做的自动启动Selenium Grid中心服务器。
复制srvany.exe
为c:\tools\srvany\srvany.exe
打开CMD窗口管理和运行:
$ cd C:\tools\srvany
$ sc create "Selenium Grid Hub Server" binPath= c:\tools\srvany\srvany.exe DisplayName= "Selenium Grid Hub Server"
注册表编辑
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Selenium Grid Hub Server
一DD名为Parameters
根据该密钥的新密钥,添加名为3个新的字符串值:
Application
=>${JAVA_HOME}/bin/java.exe
AppParameters
=>-jar selenium-server-standalone-2.42.2.jar -role hub
AppDirectory
=>C:\tools\selenium
此信用转至http://codeforjava.blogspot.com/2010/12/run-java-application-as-windows-nt.html
- 1. 作为服务器运行的Windows 7
- 2. 在Debian/Ubuntu上运行Jetty 7服务...
- 3. 作为Windows服务运行时未找到Jetty WebAppContext
- 4. 在Windows服务器上运行jetty + solr
- 5. 将lighttpd作为Windows服务运行
- 6. 将WEBrick作为Windows服务运行
- 7. 将Selenium RC作为Windows服务运行
- 8. 将Django作为Windows服务运行
- 9. 将Elastic Search作为Windows服务运行
- 10. 将.bat作为Windows服务运行
- 11. 将JAR作为Windows服务运行
- 12. 将Apache Derby作为Windows服务运行
- 13. 将IKVM exe作为Windows服务运行
- 14. 将Tomcat Servlet作为Windows服务运行
- 15. 运行Web服务作为Windows服务
- 16. 作为Windows服务运行咆哮
- 17. 运行Python脚本作为Windows服务
- 18. 运行WCF Windows服务作为InstanceContextMode.PerCall
- 19. PCSC.InvalidContextException作为Windows服务运行时
- 20. ClassNotFoundException的同时运行码头7.6作为Windows服务
- 21. 运行JBoss 7.1.1.Final作为Windows服务
- 22. 在Windows上作为服务运行Redis
- 23. 将Java应用程序作为Windows 7服务运行时获取“GPG错误”
- 24. 将Jetty设置为服务
- 25. 将WSO2作为Windows服务运行时,代理不起作用
- 26. 将Rails作为Windows服务运行时,系统DSN不工作
- 27. Windows 7作为公共服务器
- 28. 作为Windows 7服务的GlassFish 4.0
- 29. 使用NIO作为Windows服务运行Tomcat服务器
- 30. 如何停止作为Windows服务运行的web.py服务器
感谢您的信息。只是为了让你知道:为了正常工作,我必须设置JAVA_HOME环境变量。 – 2012-04-29 08:28:21
用户界面特别有助于双重检查正在使用的Java运行时。并确保JAVA_HOME设置在* System *环境变量中,而不是用户的。否则,这一切都适合你,但不适合服务。 – 2012-09-13 14:11:15