. */ namespace GnuBoat; require_once(__DIR__ ."/../autoloader.php"); class ServiceShutdown extends Service { function __construct() { parent::__construct(); } protected function process() { $debug = $this->debug(); $config = new Config(); $handle = @fopen($config->shutdownRequestFile(), "w"); if($handle === false){ $message = "Could not create file (". $config->shutdownRequestFile() .") to indicate shutdown to the daemon."; return $this->error($message, ["shutdownstart" => -1]); } $shutdownTime = new \DateTime('NOW'); $shutdownTime->modify("+15 seconds"); fwrite($handle, $shutdownTime->format(\DateTime::ATOM)); fclose($handle); $result["shutdownstart"] = $shutdownTime->format(\DateTime::ATOM); $this->output($result); } } ?>