codahale/dropwizard — pull request #22 by nicktelford (2012-01-20 14:33:12+00:00)
Title: Adds dropwizard-daemon contrib module

As discussed (briefly) on the mailing list:

Provides an Apache Commons Daemon (jsvc and procrun) wrapper around Dropwizard Services.
Services and Configurations are defined as normal, but the user can optionally define a ServiceDaemon implementation that provides the daemon wrapper with a Service instance to wrap.

The Good:
* Doesn't touch any core interfaces so existing Services can easily be wrapped by defining an additional class.
* Services are only wrapped if launched through jsvc/procrun - you can still write your Service main() method as usual for running under other circumstances.

The Bad:
* Commons Daemon recommends that priviliged operations (e.g. binding ServerSockets) is done in init() because it may (e.g. under jsvc) be called as a super-user before dropping privileges for calling start(). As we don't have access to the underlying socket binding, it has to be done in start() so may not have super-user privileges.

The Ugly:
* This basically extracts the LifeCycle start behaviour from main() -> ConfiguredCommand.run() -> ServerCommand.run(). I didn't want to rock the boat too much so opted to duplicate code rather than refactor the LifeCycle management out to a more accessible place. This can be improved upon in the future.