/** * Handles DaemonCore requests. * * @param string $Input * @return boolean */ public static function Start($Input) { System_Daemon::debug('Starting "DaemonCore::Start" subprocess.'); $retVal = null; $Input = explode(" ", $Input, 2); switch ($Input[0]) { case 'checkAll': $retVal = self::checkAllData(); break; case 'Restart': System_Daemon::info('Running Restart subprocess.'); SocketHandler::Close(); System_Daemon::restart(); break; case 'SaveConfig': System_Daemon::debug('Running SaveConfig subprocess.'); if (isset($Input[1]) && is_array($Input[1])) { foreach (json_decode(trim($Input[1])) as $name => $wert) { if (isset(DaemonConfig::$cfg->{$name})) { DaemonConfig::$cfg->{$name} = $wert; } } } DaemonConfig::Save(); DaemonConfig::SaveOldConfig(); System_Daemon::debug('Finished SaveConfig subprocess.'); $retVal = true; break; case 'Setup': if (file_exists(dirname(__FILE__) . '/DaemonCoreSetup.php')) { require_once dirname(__FILE__) . '/DaemonCoreSetup.php'; if (isset($Input[1]) && $Input[1] != '') { $retVal = Setup($Input[1]); } } else { $retVal = false; } break; default: System_Daemon::warning("Don't know what to do with " . $Input[0]); $retVal = false; break; } System_Daemon::debug('Finished "DaemonCore::Start" subprocess.'); return $retVal; }
#!/usr/bin/php -q <?php // Make it possible to test in source directory // This is for PEAR developers only ini_set('include_path', ini_get('include_path') . ':..'); // Include Class error_reporting(E_ALL); // Start System Daemon (PEAR) require_once "System/Daemon.php"; // Allowed arguments & their defaults $runmode = array("no-daemon" => true, "help" => false, "write-initd" => false); // Options $options = array('appName' => 'queue_test', 'appDir' => dirname(__FILE__), 'sysMaxExecutionTime' => '0', 'sysMaxInputTime' => '0', 'sysMemoryLimit' => '1024M'); System_Daemon::setOptions($options); // Overrule the signal handler with any function System_Daemon::setSigHandler(SIGCONT, array("System_Daemon", "defaultSigHandler")); System_Daemon::start(); System_Daemon::restart(); System_Daemon::stop();