sonatype/nexus-oss — pull request #702 by mcculls (2014-09-02 12:23:29+00:00)
Title: NEXUS-6742: NEXUS-6791: exit process if Nexus is already running

https://issues.sonatype.org/browse/NEXUS-6742
https://issues.sonatype.org/browse/NEXUS-6791

This PR provides an implementation of Karaf's system lock that uses the Nexus lock file approach to detect whether another Nexus instance is already running and if so exit the current process. It uses a copy of the LockFile class from nexus-bootstrap, slimmed down further so it works in the more restricted Karaf launcher environment (where even logging may not have been fully initialised yet).

Note: it locks the base directory rather than the work directory, because we haven't processed any application configuration at this point. It also uses "lock" as the lock-file name to match Karaf's standard behaviour - but if people prefer then we can rename this to "nexus.lock".