public function testLogger()
 {
     $logger = ExtenderLogger::create(true);
     $this->assertInstanceOf('\\Monolog\\Logger', $logger);
 }
 protected function setUp()
 {
     $this->color = new \Console_Color2();
     $this->debug = ExtenderLogger::create(false);
 }
Esempio n. 3
0
 /**
  * Constructor method
  *
  * Prepare extender environment, do checks and fire extender.ready event
  */
 public final function __construct()
 {
     // check if extender is running from cli
     if (Checks::cli() === false) {
         echo "Extender runs only in php-cli, exiting";
         self::end(1);
     }
     // setup default timezone (in daemon mode, timezone warning may break extender)
     $default_timezone = ini_get('date.timezone');
     if (empty($default_timezone)) {
         date_default_timezone_set(defined('EXTENDER_TIMEZONE') ? EXTENDER_TIMEZONE : 'Europe/Rome');
     }
     $this->timestamp_absolute = microtime(true);
     $this->color = new Console_Color2();
     // get command line options (vsdh)
     list($this->verbose_mode, $this->debug_mode, $this->summary_mode, $this->daemon_mode, $help_mode) = self::getCommandlineOptions();
     if ($help_mode) {
         self::showHelp($this->color);
         self::end(0);
     }
     $this->logger = ExtenderLogger::create($this->verbose_mode, $this->debug_mode);
     // do checks
     $check_constants = Checks::constants();
     if ($check_constants !== true) {
         $this->logger->critical($check_constants);
         self::end(1);
     }
     if (Checks::signals() === false and $this->daemon_mode) {
         $this->logger->critical("Extender cannot run in daemon mode without PHP Process Control Extensions");
         self::end(1);
     }
     if (Checks::database() === false) {
         $this->logger->critical("Extender database not available, exiting");
         self::end(1);
     }
     $this->tasks = TasksTable::load($this->logger);
     $this->events = Events::load($this->logger);
     // setup extender parameters
     $this->max_result_bytes_in_multithread = defined('EXTENDER_MAX_RESULT_BYTES') ? filter_var(EXTENDER_MAX_RESULT_BYTES, FILTER_VALIDATE_INT) : 2048;
     $this->max_childs_runtime = defined('EXTENDER_MAX_CHILDS_RUNTIME') ? filter_var(EXTENDER_MAX_CHILDS_RUNTIME, FILTER_VALIDATE_INT) : 600;
     $this->multithread_mode = defined('EXTENDER_MULTITHREAD_ENABLED') ? filter_var(EXTENDER_MULTITHREAD_ENABLED, FILTER_VALIDATE_BOOLEAN) : false;
     // if in daemon mode, remember parent pid, setup lock and register signal handlers
     if ($this->daemon_mode) {
         $this->parent_pid = posix_getpid();
         Lock::register($this->parent_pid);
         $this->adjustNiceness();
         if (Checks::signals()) {
             $this->registerSignals();
         }
     }
     // init the runner
     $this->runner = new JobsRunner($this->logger, $this->getMultithreadMode(), $this->max_result_bytes_in_multithread, $this->max_childs_runtime);
     $this->logger->notice("Extender ready");
     // store initial status and queue information
     Status::dump($this->timestamp_absolute, $this->parent_pid, $this->completed_processes, $this->failed_processes, $this->paused);
     Queue::dump(0, 0);
     // we are ready to go!
 }
 protected function setUp()
 {
     $debug = ExtenderLogger::create(false);
     $this->task = TasksTable::load($debug);
 }