@Test public void testDeletePidFileIfOwned_WithProperPidFile_RemovesPIDFile() throws IOException { mockGetCurrentPid("1000"); Files.write(this.regularFile.toPath(), "1000".getBytes(), StandardOpenOption.APPEND); Assert.assertTrue(this.regularFile.exists()); ServerUtil.deletePidFileIfOwned(this.regularFile.getPath()); Assert.assertFalse(this.regularFile.exists()); }
public static void deletePidFileIfOwned(String filename) { Integer filePid; try { filePid = readPIDFromFile(filename); } catch (CorruptedPidException e) { log.error("PID number is corrupted", e); return; } if (filePid != null) { String PID = String.valueOf(filePid); if (PID.equals(getCurrentPid())) { log.info("Pid from File " + filename + " Matches current pid. Deleting the PID."); new File(filename).delete(); } else { log.info("Pid: " + filePid + " Does not match current Pid: " + getCurrentPid() + " Assuming upgrade, Not deleting pid file:" + filename); } } }
ServerUtil { public static void deletePidFileIfOwned(String filename) { Integer filePid; try { filePid = readPIDFromFile(filename); } catch (CorruptedPidException e) { log.error("PID number is corrupted", e); return; } if (filePid != null) { String PID = String.valueOf(filePid); if (PID.equals(getCurrentPid())) { log.info("Pid from File " + filename + " Matches current pid. Deleting the PID."); new File(filename).delete(); } else { log.info("Pid: " + filePid + " Does not match current Pid: " + getCurrentPid() + " Assuming upgrade, Not deleting pid file:" + filename); } } } }
ServerUtil { public static void deletePidFileIfOwned(String filename) { Integer filePid; try { filePid = readPIDFromFile(filename); } catch (CorruptedPidException e) { log.error("PID number is corrupted", e); return; } if (filePid != null) { String PID = String.valueOf(filePid); if (PID.equals(getCurrentPid())) { log.info("Pid from File " + filename + " Matches current pid. Deleting the PID."); new File(filename).delete(); } else { log.info("Pid: " + filePid + " Does not match current Pid: " + getCurrentPid() + " Assuming upgrade, Not deleting pid file:" + filename); } } }  }
ServerUtil { public static void deletePidFileIfOwned(String filename) { Integer filePid; try { filePid = readPIDFromFile(filename); } catch (CorruptedPidException e) { log.error("PID number is corrupted", e); return; } if (filePid != null) { String PID = String.valueOf(filePid); if (PID.equals(getCurrentPid())) { log.info("Pid from File " + filename + " Matches current pid. Deleting the PID."); new File(filename).delete(); } else { log.info("Pid: " + filePid + " Does not match current Pid: " + getCurrentPid() + " Assuming upgrade, Not deleting pid file:" + filename); } } }  static long getUptime(); static String uptimeToString(); static String uptimeToString(long uptime); static Long getUsableDiscSpaceInGB(); static boolean isEnoughSpace(); static String getCurrentPid(); static boolean isWindows(); static void stopServerProcess(String pidFile); static void terminateProcessByPid(Integer pid); static void writePIDToFile(String filename); static void writePIDToFile(String filename, String pid); static String getPidByProcessName(String processName); static void deletePidFileIfOwned(String filename); static boolean startAgentProcess(); static boolean startAgentProcess(int waitTimeout, ServerServiceChecker serverServiceChecker); static boolean startServerProcess(); static boolean startServerProcess(int waitTimeout, ServerServiceChecker serverServiceChecker); static boolean startServerProcess(int waitTimeout, ServerServiceChecker serverServiceChecker,
            boolean isRebootAfterFailure); static int execWithLog(String cmd); static int execWithLog(String[] cmd); static int execWithLog(String cmd, List<String> lines); static int execWithLog(String[] cmd, List<String> lines); static int execWithLog(String[] cmd, boolean logCommandLine); static int execWithLog(String[] cmd, List<String> lines, boolean logCommandLine); static int execWithLines(String cmd, List<String> outLines); static int execWithLines(String[] cmd, List<String> outLines, boolean logCommand); static String getServerIP(); static void setServerIP(String serverIP); static Thread getTimeMonitorThread(final TimeChangeCommand timeChangeCommand, final long timeChangeThreshold,
            final long sleepInterval); }
ServerUtil { public static void deletePidFileIfOwned(String filename) { Integer filePid; try { filePid = readPIDFromFile(filename); } catch (CorruptedPidException e) { log.error("PID number is corrupted", e); return; } if (filePid != null) { String PID = String.valueOf(filePid); if (PID.equals(getCurrentPid())) { log.info("Pid from File " + filename + " Matches current pid. Deleting the PID."); new File(filename).delete(); } else { log.info("Pid: " + filePid + " Does not match current Pid: " + getCurrentPid() + " Assuming upgrade, Not deleting pid file:" + filename); } } }  static long getUptime(); static String uptimeToString(); static String uptimeToString(long uptime); static Long getUsableDiscSpaceInGB(); static boolean isEnoughSpace(); static String getCurrentPid(); static boolean isWindows(); static void stopServerProcess(String pidFile); static void terminateProcessByPid(Integer pid); static void writePIDToFile(String filename); static void writePIDToFile(String filename, String pid); static String getPidByProcessName(String processName); static void deletePidFileIfOwned(String filename); static boolean startAgentProcess(); static boolean startAgentProcess(int waitTimeout, ServerServiceChecker serverServiceChecker); static boolean startServerProcess(); static boolean startServerProcess(int waitTimeout, ServerServiceChecker serverServiceChecker); static boolean startServerProcess(int waitTimeout, ServerServiceChecker serverServiceChecker,
            boolean isRebootAfterFailure); static int execWithLog(String cmd); static int execWithLog(String[] cmd); static int execWithLog(String cmd, List<String> lines); static int execWithLog(String[] cmd, List<String> lines); static int execWithLog(String[] cmd, boolean logCommandLine); static int execWithLog(String[] cmd, List<String> lines, boolean logCommandLine); static int execWithLines(String cmd, List<String> outLines); static int execWithLines(String[] cmd, List<String> outLines, boolean logCommand); static String getServerIP(); static void setServerIP(String serverIP); static Thread getTimeMonitorThread(final TimeChangeCommand timeChangeCommand, final long timeChangeThreshold,
            final long sleepInterval);  }