Package org.elasticsearch.common
Class PidFile
java.lang.Object
org.elasticsearch.common.PidFile
public final class PidFile
extends java.lang.Object
Process ID file abstraction that writes the current pid into a file and optionally
removes it on system exit.
-
Method Summary
Modifier and Type Method Description static PidFilecreate(java.nio.file.Path path, boolean deleteOnExit)Creates a new PidFile and writes the current process ID into the provided pathjava.nio.file.PathgetPath()Returns the process id file pathlonggetPid()Returns the current process idbooleanisDeleteOnExit()Returnstrueiff the process id file is deleted on system exit.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
create
public static PidFile create(java.nio.file.Path path, boolean deleteOnExit) throws java.io.IOExceptionCreates a new PidFile and writes the current process ID into the provided path- Parameters:
path- the path to the pid file. The file is newly created or truncated if it already existsdeleteOnExit- iftruethe pid file is deleted with best effort on system exit- Throws:
java.io.IOException- if an IOException occurs
-
getPid
public long getPid()Returns the current process id -
getPath
public java.nio.file.Path getPath()Returns the process id file path -
isDeleteOnExit
public boolean isDeleteOnExit()Returnstrueiff the process id file is deleted on system exit. Otherwisefalse.
-