Ejemplo n.º 1
0
 /**
  * update - обновляет конфигурацию системы
  *
  * @param mixed $config_file
  * @static
  * @access public
  * @return void
  */
 public static function update($config_file = false)
 {
     $config_file = $config_file ?: Config::get('Flags.config');
     if (self::load($config_file)) {
         return Config::set('Flags.config', $config_file);
     }
 }
Ejemplo n.º 2
0
 protected static function getLogFileName($name)
 {
     $logDir = Config::get('Logger.log_dir');
     if (!preg_match("#^\\/#", $logDir)) {
         $logDir = Config::get('project_root') . "/" . rtrim($logDir, '/');
     }
     return $logDir . '/' . strtolower($name) . '.log';
 }
Ejemplo n.º 3
0
 protected static function getPidFileName()
 {
     $pidDir = Config::get('Daemon.pid_dir');
     if (!preg_match("#^\\/#", $pidDir)) {
         $pidDir = Config::get('project_root') . "/" . rtrim($pidDir, '/');
     }
     return $pidDir . '/' . static::getName() . '.pid';
 }
Ejemplo n.º 4
0
 protected function isItTimeToDie()
 {
     return microtime(true) - $this->start_time > Config::get('Daemon.child_ttl');
 }
Ejemplo n.º 5
0
 public function deleteChildCollection($name = self::MAIN_COLLECTION_NAME)
 {
     if (!empty($name) && !empty($this->child_collections[$name])) {
         $collection = $this->child_collections[$name];
         $collection->stop();
         //ждем, пока не остановятся все дочерние процессы
         static::log('Waiting for all children of "' . $name . '" collection to shutdown...', Logger::L_INFO);
         static::log('"' . $name . '" collection: ' . $collection->getNumber() . ' of child threads remaining...', Logger::L_INFO);
         while ($collection->getNumber() > 0) {
             $this->sigwait(Config::get('Daemon.master_sigwait'));
             continue;
         }
         unset($this->child_collections[$name]);
         return true;
     }
 }
Ejemplo n.º 6
0
 public function sighup()
 {
     static::log("Got signal to update config");
     if (Config::update()) {
         Logger::init();
     }
 }
Ejemplo n.º 7
0
#!/usr/bin/php -q
<?php 
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
require 'Example.php';
use Daemon\Daemon;
use Daemon\Utils\Config;
// run main cycle
Config::set('project_root', __DIR__);
Daemon::run(new Master(), 'config.yml');