Ejemplo n.º 1
0
 /**
  * Start script.
  * @return void
  */
 public static function start()
 {
     if (Daemon_Bootstrap::$pid && posix_kill(Daemon_Bootstrap::$pid, SIGTTIN)) {
         Daemon::log('[START] phpDaemon with pid-file \'' . Daemon::$config->pidfile->value . '\' is running already (PID ' . Daemon_Bootstrap::$pid . ')');
         exit;
     }
     Daemon::init();
     $pid = Daemon::spawnMaster();
     file_put_contents(Daemon::$config->pidfile->value, $pid);
 }
Ejemplo n.º 2
0
#!/usr/bin/php
<?php 
require_once 'config.php';
(PHP_SAPI !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && die('This daemon can only run in CLI');
if (isset($argv[1]) && !empty($argv[1])) {
    if (is_file(dirname(__FILE__) . '/profiles/' . $argv[1] . '/config.php')) {
        require dirname(__FILE__) . '/profiles/' . $argv[1] . '/config.php';
    } else {
        die('NO PROFILE SELECTED');
    }
    if (isset($argv[2]) && !empty($argv[2])) {
        Daemon::init($settings, $argv);
    } else {
        die('NO HASH');
    }
}
Ejemplo n.º 3
0
 public static function run($rootPath)
 {
     if (!defined('DS')) {
         define('DS', DIRECTORY_SEPARATOR);
     }
     self::$zPath = \dirname(__DIR__);
     self::setRootPath($rootPath);
     if (!isset($_SERVER['argv'][1])) {
         die('plz set config path.');
     }
     $configPath = $_SERVER['argv'][1];
     self::setConfigPath($configPath);
     self::setsArea($configPath);
     //sArea
     \spl_autoload_register(__CLASS__ . '::autoLoader');
     if (!self::checkConfigPath()) {
         die("wrong config path[{$configPath}]");
     }
     Config::load(self::getConfigPath());
     if (Config::get('debug_mode', 1)) {
         //            error_reporting(E_ALL & ~E_NOTICE | E_STRICT);
         error_reporting(E_ALL & ~E_NOTICE & ~E_USER_NOTICE & ~E_USER_WARNING | E_STRICT);
         ini_set('display_errors', 1);
     } else {
         error_reporting(0);
         ini_set('display_errors', 0);
     }
     $appPath = Config::get('app_path', self::$appPath);
     self::setAppPath($appPath);
     //@todo set exception error handle...
     $timeZone = Config::get('time_zone', 'Asia/Shanghai');
     \date_default_timezone_set($timeZone);
     ini_set("memory_limit", Config::get('memory_limit', -1));
     Daemon::init();
 }
<?php

require_once 'config.php';
(PHP_SAPI !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && die('This daemon can only run in CLI');
Daemon::init();
close();