public static function resume()
 {
     if (Checks::signals() === false) {
         throw new Exception("This version of PHP does not support pnctl");
     }
     try {
         $pid = self::pushUsrEvent(SIGCONT, self::$lockfile);
     } catch (Exception $e) {
         throw $e;
     }
     return $pid;
 }
Exemplo n.º 2
0
 /**
  * Get multithread mode status
  *
  * @return  bool    True if enabled, false if disabled
  */
 public final function getMultithreadMode()
 {
     return ($this->multithread_mode and Checks::multithread()) ? true : false;
 }
Exemplo n.º 3
0
 /**
  * Change child process priority according to EXTENDER_NICENESS
  *
  */
 private static function adjustNiceness($pid, $logger)
 {
     if (Checks::multithread() and defined("EXTENDER_CHILD_NICENESS")) {
         $niceness = pcntl_setpriority($pid, EXTENDER_CHILD_NICENESS);
         if ($niceness == false) {
             $logger->warning("Unable to set child process " . $pid . " niceness to " . EXTENDER_CHILD_NICENESS);
         }
     }
 }
Exemplo n.º 4
0
 /**
  * econtrol constructor
  *
  */
 public function __construct()
 {
     // check if econtrol is running from cli
     if (Checks::cli() === false) {
         echo "Econtrol runs only in php-cli, exiting";
         self::end(1);
     }
     if (defined('EXTENDER_TIMEZONE')) {
         date_default_timezone_set(EXTENDER_TIMEZONE);
     }
     $this->color = new Console_Color2();
     $this->parser = new Console_CommandLine(array('description' => Version::getDescription(), 'version' => Version::getVersion()));
     // add verbose option
     $this->parser->addOption('verbose', array('short_name' => '-v', 'long_name' => '--verbose', 'description' => 'turn on verbose output', 'action' => 'StoreTrue'));
     // add debug option
     $this->parser->addOption('debug', array('short_name' => '-V', 'long_name' => '--debug', 'description' => 'turn on debug output', 'action' => 'StoreTrue'));
     try {
         $check_constants = Checks::constants();
         if ($check_constants !== true) {
             throw new ShellException($check_constants);
         }
         if (array_key_exists('V', getopt("V"))) {
             $verbose = 'DEBUG';
             echo $this->color->convert("\n%r(> Debug mode on <)%n\n");
         } else {
             if (array_key_exists('v', getopt("v"))) {
                 $verbose = 'NOTICE';
                 echo $this->color->convert("\n%y(> Verbose mode on <)%n\n");
             } else {
                 $verbose = false;
             }
         }
         $this->logger = EcontrolLogger::create($verbose);
         $this->tasks = TasksTable::load($this->logger);
         $this->controller = Controller::load($this->parser, $this->logger);
     } catch (Console_CommandLine_Exception $ce) {
         $this->parser->displayError($this->color->convert("\n\n%y" . $ce->getMessage() . "%n\n"));
         self::end(1);
     } catch (ShellException $se) {
         $this->parser->displayError($this->color->convert("\n\n%R" . $se->getMessage() . "%n\n"));
         self::end(1);
     } catch (Exception $e) {
         $this->parser->displayError($this->color->convert("\n\n%r" . $e->getMessage() . "%n\n"));
         self::end(1);
     }
 }