2010-01-19 35 views

Trả lời

24

@glb, cảm ơn vì đã chỉ ra apache commons-daemon Procrun.
Làm việc tuyệt vời cho tôi trên Windows 7 64 Bit, đây là cách tôi thiết lập nó.

Để biết thêm thông thấy

  • procrun trang theo liên kết từ @glb
  • cầu cảng giúp đỡ màn hình> 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 

hoàn tất!

+1

Cảm ơn bạn đã thông tin. Chỉ cần để cho bạn biết: để làm việc này đúng cách, tôi phải đặt biến môi trường JAVA_HOME. –

+0

Giao diện người dùng đặc biệt hữu ích để kiểm tra kỹ xem thời gian chạy Java nào đang được sử dụng. Và đảm bảo rằng JAVA_HOME được đặt trong các biến môi trường * Hệ thống *, không phải biến của người dùng. Nếu không, tất cả sẽ hoạt động cho bạn, nhưng không phải cho dịch vụ. –

3

Trong phiên bản ổn định mới nhất của Java Service Wrapper (JSW 3.4.1) có WrapperJarApp phương pháp tích hợp:

Đây là một phần của cấu hình của tôi:

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

Trong các thử nghiệm ban đầu của tôi với điều này, Jetty dường như hoạt động tốt nhất nếu JSW được khởi chạy từ '% JETTY_HOME%' (tức là thả các cấu hình JSW, jar và DLL vào thư mục cài đặt Jetty). Bằng cách này, nếu Jetty nhìn xung quanh cho các thiết lập cấu hình liên quan đến đường dẫn hiện tại dịch vụ đang chạy từ vị trí mong muốn. – mckamey

3

Hãy xem Procrun từ Apache Commons . Bạn sẽ muốn duyệt khu vực tải xuống tệp nhị phân gốc để lấy các tệp nhị phân Windows.

2

Bạn có thể lấy src từ: http://svn.codehaus.org/jetty/jetty/branches/jetty-7/jetty-win32/ và tự xây dựng.

Nhưng tôi đã cài đặt trình bao bọc theo cách thủ công như bất kỳ cài đặt trình bao bọc “tiêu chuẩn” nào.

Đã file Jetty-Service.conf gốc và thay đổi:

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

Và thêm ...

wrapper.app.parameter.1 = org.eclipse.jetty.start.Main < - lớp Main wrapper.app.parameter.2 = ../etc/cầu cảng. xml wrapper.app.parameter.x = ../etc /jetty-x.xml < --Bất kỳ tệp cấu hình bổ sung nào mà bạn muốn bao gồm… wrapper.app.parameter.y = ../etc/jetty-y.xml

Dường như bắt đầu tốt và có vẻ như tắt máy duyên dáng quá.

1

Tôi gặp sự cố khi chạy mã @ crowne để cài đặt dịch vụ (Tôi đang chạy Jetty 8.1.0). Chỉ cần thay đổi -StartMode=Java --StopMode=Java thành -StartMode=jvm --StopMode=jvm và xóa ++JvmOptions=-XX:+CMSPermGenSweepingEnabled.

Sau đó tôi đã tạo ra một create_jetty_service.bat tại cầu cảng/thư mục bin và chạy tập tin từ đó:

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 

Hãy nhớ để chạy cmd.exe as administrator để lệnh có hiệu lực.

2

Bạn có thể chạy như một dịch vụ Windows Jetty có thể được sử dụng để exewrap.
Dịch vụ Windows Jetty Tất cả trong một gói cũng được phân phối.

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

1

Nếu bạn đang ở trong một chút của một môi trường bị khóa xuống và cần phải ở trong Microsoft cung cấp công cụ thiết lập, sau đó srvany, instsrvsc là bạn bè. Thật không may, nó thường bao gồm chỉnh sửa registry. Điều tốt đẹp là nó rất linh hoạt.

Dưới đây là những gì tôi đã làm gần đây để tự động khởi động máy chủ trung tâm Lưới điện Selenium.


Sao chép srvany.exe vào c:\tools\srvany\srvany.exe

cửa sổ cmd mở như admin và chạy:

$ 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

Một dd một chìa khóa mới có tên Parameters Theo quan trọng mà, thêm 3 giá trị chuỗi mới có tên:

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

Khoản tín dụng này sẽ chuyển đến http://codeforjava.blogspot.com/2010/12/run-java-application-as-windows-nt.html

Các vấn đề liên quan