views:

1302

answers:

2

I'm looking for a tool to run java server processes as daemon services in Linux (and potentially on Windows and other OS's). I'm looking for the best practices when it comes to how to build production capable scripts and launch configuration.

I'm familiar with best practices when it comes to a project's build, using Apache Maven, or something like Apache ANT + Ivy to manage your build process and manage external dependencies and build artifacts and assemblies.

When it comes to creating a project's assembly containing configuration and launch scripts along with all the compiled code and dependencies I'm unclear what the best choice is. Is there a good open source project that I could look at as an example, that bundles a service wrapper and configuration scripts with their build process?

I've been able to use Maven with the Jetty Launch plugin to run my Web applications, Terracotta Maven plugin to test multiple JVM clustered server nodes and I've used Maven's exec:java to run my custom Java servers, but I'm not sure using Maven in that capacity is really "production" quality, also it means my production servers depend on building the servers from source and downloading dependencies from potentially unavailable servers.

Here are some potential things I'm looking for in a Java service launcher solution:

  1. Should run as a Linux service or Windows service process
  2. Can be built using a Maven plugin or Ant script and allow me to process configuration files and scripts
  3. Should be able to include all my project's dependencies from Apache Ant
  4. Should be able to pull in a full Java Web Application server (e.g. Jetty 7) and be configured with my custom Web application's war
  5. Should be able to handle a standard Java daemon service (custom java server)

Some of the options I've been looking at are Java Service Wrapper, which is used in the Maven appassembler plugin.

Also using Maven's assembly plugin and custom assembly descriptors allows me to tailor the build output.

+3  A: 

The preferred (aka "best practice") way to implement Linux services of all kinds is to create a shell script that can start, stop and restart the service and put it into /etc/init.d. Then add appropriately symlinks to it from the relevant "rc.*" directories. Refer to the Linux "man" entries for "init(8)", "chkconfig(8)" and so on.

Stephen C
+3  A: 

The Java Service Wrapper seems to be quite common. I've seen it used by a few people, most notably in nexus.

Dominic Mitchell