Esempio n. 1
0
 protected function stopDaemon()
 {
     $pid = $this->getRunningPid();
     if (!$pid) {
         $this->logger->notice("Cannot stop the daemon as it is not started");
         return "notstarted";
     }
     $this->logger->info("Trying to terminate the daemon", array('pid' => $pid));
     $this->processControl->kill($pid);
     for ($i = 0; ($pid = $this->getRunningPid()) && $i < 5; $i++) {
         sleep(1);
     }
     if ($pid) {
         $this->logger->warning("The daemon is resiting, trying to kill it", array('pid' => $pid));
         $this->processControl->kill($pid, true);
         for ($i = 0; ($pid = $this->getRunningPid()) && $i < 5; $i++) {
             sleep(1);
         }
     }
     if (!$pid) {
         $this->logger->notice("Daemon stopped");
         return "stopped";
     }
     $this->logger->error("Could not stop the daemon");
 }
Esempio n. 2
0
 public function testForcefullyKill()
 {
     if (!$this->object->isAvailable()) {
         $this->markTestSkipped();
     }
     $pid = $this->startProcess();
     $this->object->kill($pid, true);
     usleep(500);
     $this->assertFalse($this->isRunning());
 }