コード例 #1
0
ファイル: crawl_daemon.php プロジェクト: yakar/yioop
 /**
  * Used to stop a daemon that is running in the background
  *
  * @param string $name the main name of this daemon such as queue_server
  *     or fetcher.
  * @param string $subname the instance name if it is possible for more
  *     than one copy of the daemon to be running at the same time
  * @param bool $exit whether this method should just return (false) or
  *      call exit() (true)
  */
 static function stop($name, $subname = "", $exit = true)
 {
     $name_string = CrawlDaemon::getNameString($name, $subname);
     $lock_file = CrawlDaemon::getLockFileName($name, $subname);
     $not_web_setting = php_sapi_name() == 'cli';
     if (file_exists($lock_file)) {
         unlink($lock_file);
         if ($not_web_setting) {
             crawlLog("Sending stop signal to {$name_string}...");
         }
     } else {
         if ($not_web_setting) {
             crawlLog("{$name_string} does not appear to running...");
         }
     }
     if ($exit) {
         exit;
     }
 }