- $this->pidfile = new Pidfile($lockpath, $host);
- if ($this->pidfile->isRunning()) {
- $oldpid = $this->pidfile->pid();
- $this->writeLog(LOG_INFO, 'Process ' . $oldpid . ' was running for ' . $this->pidfile->runningTime() . ' seconds and will now be killed');
- $this->pidfile->kill();
-
- // Wait until the other process is hopefully killed
- sleep(2);
-
- $this->pidfile = new Pidfile($lockpath, $host);
- if ($oldpid == $this->pidfile->pid()) {
- $this->writeLog(LOG_ERR, 'Process ' . $oldpid . "wasn't killed in time. We now quit our process.");
+ $file = $lockpath . DIRECTORY_SEPARATOR . $host;
+ if (PidFile::isRunningProcess($file)) {
+ if (PidFile::killProcess($file)) {
+ $this->writeLog(LOG_INFO, 'Old process was successfully killed');
+ } else {
+ $this->writeLog(LOG_ERR, "The old Process wasn't killed in time. We now quit our process.");