Permalink
Browse files

[fixes #342] allow more flexibility when it comes to PID file handling

  • Loading branch information...
1 parent bc0f0b4 commit 17c750b36c91c59709794c9505e433d7ba5a8f21 @pk11 pk11 committed Jun 4, 2012
Showing with 13 additions and 13 deletions.
  1. +13 −13 framework/src/play/src/main/scala/play/core/server/NettyServer.scala
@@ -147,26 +147,26 @@ object NettyServer {
* @param applicationPath path to application
*/
def createServer(applicationPath: File): Option[NettyServer] = {
-
// Manage RUNNING_PID file
java.lang.management.ManagementFactory.getRuntimeMXBean.getName.split('@').headOption.map { pid =>
- val pidPath = Option(System.getProperty("pidfile.path")).getOrElse(applicationPath.getAbsolutePath())
- val pidFile = new File(pidPath, "RUNNING_PID")
-
- if (pidFile.exists) {
- println("This application is already running (Or delete the RUNNING_PID file).")
- System.exit(-1)
- }
+ val pidFile = Option(System.getProperty("pidfile.path")).map(new File(_)).getOrElse(new File(applicationPath.getAbsolutePath, "RUNNING_PID"))
// The Logger is not initialized yet, we print the Process ID on STDOUT
println("Play server process ID is " + pid)
- new FileOutputStream(pidFile).write(pid.getBytes)
- Runtime.getRuntime.addShutdownHook(new Thread {
- override def run {
- pidFile.delete()
+ if (pidFile.getAbsolutePath != "/dev/null") {
+ if (pidFile.exists) {
+ println("This application is already running (Or delete "+ pidFile.getAbsolutePath +" file).")
+ System.exit(-1)
}
- })
+
+ new FileOutputStream(pidFile).write(pid.getBytes)
+ Runtime.getRuntime.addShutdownHook(new Thread {
+ override def run {
+ pidFile.delete()
+ }
+ })
+ }
}
try {

0 comments on commit 17c750b

Please sign in to comment.