Jetty Logo
Version: 9.2.3.v20140905
Contact the core Jetty developers at www.webtide.com

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery

Startup via Windows Service

There are no components that ship with the Jetty Distribution to make it a formal Windows Service.

However, we recommend the use of Apache ProcRun's Daemon.

The techniques outlined here are based on Windows 7 (64-bit), using JDK 7 (64-bit), running on an Intel i7 architecture machine.

Prepare System

Prepare some empty directories to work with.

C:\> mkdir opt
C:\> cd opt
C:\opt> mkdir jetty
C:\opt> mkdir logs
C:\opt> mkdir myappbase
C:\opt> mkdir temp
C:\opt> dir 
 Volume in drive C has no label.
 Volume Serial Number is DEAD-BEEF

 Directory of C:\opt

11/21/2013  04:06 PM    <DIR>          .
11/21/2013  04:06 PM    <DIR>          ..
11/21/2013  04:06 PM    <DIR>          jetty
11/21/2013  04:06 PM    <DIR>          logs
11/21/2013  04:06 PM    <DIR>          myappbase
11/21/2013  04:06 PM    <DIR>          temp
               0 File(s)              0 bytes

The directory purposes are as follows:

C:\opt

Where the service layer utilities, scripts, and binaries will eventually be

C:\opt\logs

Where the logs for the service layer will put its own logs.

Typically you will see the audit logs (install/update/delete), StdOutput, and StdError logs here.

C:\opt\jetty

Where the Jetty Distribution will be unpacked into

C:\opt\myappbase

Where your specific set of webapps will be located, including all of the configuration required of the server to make them operational.

C:\opt\temp

This is the temporary directory assigned to Java by the Service Layer (this is what Java sees as the java.io.tmpdir System Property)

This is intentionally kept separate from the standard temp directories of Windows, as this location doubles as the Servlet Spec work directory.

Make sure you have Java 7 Installed

Or download Java 7 from: http://www.oracle.com/technetwork/java/javase/downloads/index.html

C:\opt>java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

Download and Unpack Distribution

Grab a copy of the ZIP distribution from the Official Eclipse Download Site

Open it up the downloaded Zip in Windows Explorer and drag the contents of the jetty-distribution-9.2.3.v20140905 directory into place at C:\opt\jetty

Once you are complete, the contents of the C:\opt\jetty directory should look like this:

C:\opt\jetty>dir
 Volume in drive C has no label.
 Volume Serial Number is C8CF-820B

 Directory of C:\opt\jetty

11/21/2013  12:13 PM    <DIR>          .
11/21/2013  12:13 PM    <DIR>          ..
11/21/2013  12:13 PM    <DIR>          bin
11/21/2013  12:13 PM    <DIR>          demo-base
11/21/2013  12:13 PM    <DIR>          etc
11/21/2013  12:13 PM    <DIR>          lib
11/21/2013  12:13 PM            30,012 license-eplv10-aslv20.html
11/21/2013  12:13 PM    <DIR>          logs
11/21/2013  12:13 PM    <DIR>          modules
11/21/2013  12:13 PM             6,262 notice.html
11/21/2013  12:13 PM             1,249 README.TXT
11/21/2013  12:13 PM    <DIR>          resources
11/21/2013  12:13 PM    <DIR>          start.d
11/21/2013  12:13 PM             2,126 start.ini
11/21/2013  12:13 PM            72,226 start.jar
11/21/2013  12:13 PM           341,784 VERSION.txt
11/21/2013  12:13 PM    <DIR>          webapps
               6 File(s)        453,659 bytes
              11 Dir(s)  306,711,420,928 bytes free

Download and Unpack ProcRun

Download a copy of the native binaries of Apache ProcRun.

You should have downloaded a file named commons-daemon-1.0.15-bin-windows.zip (version might be different). Open this ZIP file in Windows Explorer and drag prunmgr.exe and prunsrv.exe files into the C:\opt directory.

Once you are complete, the contents of C:\opt directory should look like this:

C:\opt> dir 
 Volume in drive C has no label.
 Volume Serial Number is DEAD-BEEF

 Directory of C:\opt

11/21/2013  04:06 PM    <DIR>          .
11/21/2013  04:06 PM    <DIR>          ..
11/21/2013  04:06 PM    <DIR>          jetty
11/21/2013  04:06 PM    <DIR>          logs
11/21/2013  04:06 PM    <DIR>          myappbase
11/21/2013  04:06 PM    <DIR>          temp
11/21/2013  04:11 PM           104,448 prunmgr.exe
11/21/2013  04:11 PM            80,896 prunsrv.exe
               2 File(s)        185,344 bytes

Configure your WebApp / Jetty Base

Now it's time to setup your new ${jetty.base} directory to have all of your WebApps and the configurations that they need.

We'll start by specifying which modules we want to use (this will create a start.ini file and also create a few empty directories for you)

C:\opt\myappbase>java -jar ..\jetty\start.jar --add-to-start=deploy,http,logging

WARNING: deploy          initialised in ${jetty.base}\start.ini (appended)
WARNING: deploy          enabled in     ${jetty.base}\start.ini
MKDIR: ${jetty.base}\webapps
WARNING: server          initialised in ${jetty.base}\start.ini (appended)
WARNING: server          enabled in     ${jetty.base}\start.ini
WARNING: http            initialised in ${jetty.base}\start.ini (appended)
WARNING: http            enabled in     ${jetty.base}\start.ini
WARNING: server          enabled in     ${jetty.base}\start.ini
WARNING: logging         initialised in ${jetty.base}\start.ini (appended)
WARNING: logging         enabled in     ${jetty.base}\start.ini
MKDIR: ${jetty.base}\logs

C:\opt\myappbase>dir
 Volume in drive C has no label.
 Volume Serial Number is C8CF-820B

 Directory of C:\opt\myappbase

11/21/2013  12:49 PM    <DIR>          .
11/21/2013  12:49 PM    <DIR>          ..
11/21/2013  12:49 PM    <DIR>          logs
11/21/2013  12:49 PM             1,355 start.ini
11/21/2013  12:49 PM    <DIR>          webapps
               1 File(s)          1,355 bytes
               4 Dir(s)  306,711,064,576 bytes free

At this point you have configured your C:\opt\myappbase to enable the following modules:

deploy

This is the module that will perform deployment of web applications (WAR files or exploded directories), or Jetty IoC XML context deployables, from the C:\opt\myappbase\webapps directory.

http

This sets up a single Connector that listens for basic HTTP requests.

See the created start.ini for configuring this connector

logging

When running Jetty as a service it is very important to have logging enabled. This module will enable the basic STDOUT and STDERR capture logging to the C:\opt\myappbase\logs directory.

See Using start.jar for more details and options on setting up and configuring a ${jetty.base} directory.

At this point you merely have to copy your WAR files into the webapps directory.

C:\opt\myappbase> copy C:\projects\mywebsite.war webapps\

Configure Service Layer

At this point you should have your directories, Java, the Jetty distribution, and your webapp specifics setup and ready for operation.

We will use the Apache ProcRun's prunsrv.exe to install a Jetty Service.

The basic command line syntax is outlined in the link above.

A example install-jetty-service.bat is provided here as an example, based on the above directories.

Configuration's of note in this batch file:

SERVICE_NAME

This is the name of the service that Windows sees. The name in the Services window will show this name.

STOPKEY

This is the secret key (password) for the ShutdownMonitor, used to issue a formal command to stop the server.

STOPPORT

The port that the Shutdown Monitor listens on for the stop command.

If you have multiple Jetty servers on the same machine, this port will need to be different for each Service.

Once you have run prunsrv.exe //IS/<service-name> (done for you in the above batch file) to install the service, you can use the standard Windows utilities to manage (start/stop/restart) the Jetty service.

Start Your Service

Open the Service View and start your service.

See an error or something missing? Contribute to this documentation at Github!(Generated: 2014-11-22T01:00:25-08:00)