2010-01-19 7 views

Antwort

24

@glb, danke für den Hinweis auf Apache Commons-Daemon Procrun.
Es funktioniert gut für mich auf Windows 7 64 Bit, hier ist, wie ich es eingerichtet habe.

Für weitere Informationen siehe

  • procrun Seite per Link von @glb
  • Anlegesteg Hilfe-Bildschirm> java -jar 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 

fertig!

+1

Danke für die Info. Nur um Sie wissen zu lassen: Damit dies funktioniert, musste ich die Umgebungsvariable JAVA_HOME setzen. –

+0

Die Benutzeroberfläche ist besonders hilfreich, um zu überprüfen, welche Java-Laufzeitumgebung verwendet wird. Und stellen Sie sicher, dass JAVA_HOME in * System * -Umgebungsvariablen festgelegt ist, nicht in denen des Benutzers. Ansonsten funktioniert alles für Sie, aber nicht für den Service. –

3

In der letzten stabilen Version von Java Service Wrapper (JSW 3.4.1) gibt es WrapperJarApp Methode der Integration:

Dies ist Teil meiner Konfiguration:

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 
+0

In meinen ersten Tests scheint Jetty am besten zu funktionieren, wenn JSW von% JETTY_HOME% gestartet wird (d. H. lösche die JSW Configs, JAR und DLL in das Jetty Installationsverzeichnis). Auf diese Weise wird Jetty nach Konfigurationseinstellungen suchen, die sich auf den aktuellen Pfad beziehen, den der Dienst vom erwarteten Standort aus ausführt. – mckamey

3

einen Blick auf Procrun von den Apache Commons Nehmen . Sie sollten den Download-Bereich für native Binärdateien durchsuchen, um die Windows-Binärdateien zu erhalten.

2

Sie können die src erhalten von: http://svn.codehaus.org/jetty/jetty/branches/jetty-7/jetty-win32/ und bauen Sie es selbst.

Aber ich habe den Wrapper wie jede "Standard" -Wrapper-Installation manuell installiert.

Nahm das Original Jetty-Service.conf Datei und geändert:

wrapper.java.mainclass = org.mortbay.jetty.win32service.JettyServiceWrapperListener zu wrapper.java.mainclass = org.tanukisoftware.wrapper. WrapperSimpleApp

Und hinzugefügt ...

wrapper.app.parameter.1 = org.eclipse.jetty.start.Main < - Hauptklasse wrapper.app.parameter.2 = ../etc/Steg. xml wrapper.app.parameter.x = ../etc /jetty-x.xml < --Alle zusätzliche Konfigurationsdateien, die Sie einschließen möchten ... wrapper.app.parameter.y = ../etc/Anlegestelle-y.xml

scheint gut zu starten und es scheint, Herunterfahren anmutig auch.

1

Ich hatte ein problema läuft @ Crannes Code für die Installation des Dienstes (ich betreibe Jetty 8.1.0). Nur benötigt, um -StartMode=Java --StopMode=Java zu -StartMode=jvm --StopMode=jvm zu ändern und ++JvmOptions=-XX:+CMSPermGenSweepingEnabled zu entfernen.

Danach habe ich eine create_jetty_service.bat am Steg/bin-Ordner und führen Sie die Datei von dort:

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 

Denken Sie daran, cmd.exe als Administrator den Befehl auszuführen wirksam.

2

Sie können als Windows-Dienst ausgeführt werden Jetty kann zum Exportieren verwendet werden.
Jetty Windows Service All-in-One-Pakete werden ebenfalls verteilt.

http://exewrap.sourceforge.jp/jetty/

1

Wenn Sie in einem bisschen einer gesperrten Umgebung sind und bleiben müssen innerhalb der Microsoft-Werkzeug-Sets zur Verfügung gestellt, dann srvany, instsrv und sc sind deine Freunde. Leider beinhaltet es oft die Erstellung von Registrierungsänderungen. Das Schöne ist, dass es sehr flexibel ist.

Hier ist, was ich kürzlich getan habe, um einen Selenium Grid Hub-Server automatisch zu starten.


Copy srvany.exe in c:\tools\srvany\srvany.exe

Öffnen cmd Fenster als admin und laufen:

$ cd C:\tools\srvany 
$ sc create "Selenium Grid Hub Server" binPath= c:\tools\srvany\srvany.exe DisplayName= "Selenium Grid Hub Server" 

RegEdit

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Selenium Grid Hub Server

A dd einen neuen Schlüssel Parameters Unter diesem Schlüssel mit dem Namen, fügen Sie 3 neue String Werte genannt:

  • Application =>${JAVA_HOME}/bin/java.exe
  • AppParameters =>-jar selenium-server-standalone-2.42.2.jar -role hub
  • AppDirectory =>C:\tools\selenium

Kredit für dieses geht zu http://codeforjava.blogspot.com/2010/12/run-java-application-as-windows-nt.html