Beispiel #1
0
 /**
  * Singleton Pattern, Unique Instance of This
  *
  * @param $config_file mixed
  * @param $queueIndex
  *
  * @return static
  */
 public static function getInstance($config_file = null, $queueIndex = null)
 {
     if (PHP_SAPI != 'cli' || isset($_SERVER['HTTP_HOST'])) {
         die("This script can be run only in CLI Mode.\n\n");
     }
     declare (ticks=10);
     set_time_limit(0);
     if (static::$__INSTANCE === null) {
         if (!extension_loaded("pcntl") && (bool) ini_get("enable_dl")) {
             dl("pcntl.so");
         }
         if (!function_exists('pcntl_signal')) {
             $msg = "****** PCNTL EXTENSION NOT LOADED. KILLING THIS PROCESS COULD CAUSE UNPREDICTABLE ERRORS ******";
             static::_TimeStampMsg($msg);
         } else {
             static::_TimeStampMsg(str_pad(" Registering signal handlers ", 60, "*", STR_PAD_BOTH));
             pcntl_signal(SIGTERM, array(get_called_class(), 'sigSwitch'));
             pcntl_signal(SIGINT, array(get_called_class(), 'sigSwitch'));
             pcntl_signal(SIGHUP, array(get_called_class(), 'sigSwitch'));
             $msg = str_pad(" Signal Handler Installed ", 60, "-", STR_PAD_BOTH);
             static::_TimeStampMsg("{$msg}");
         }
         static::$__INSTANCE = new static($config_file, $queueIndex);
     }
     return static::$__INSTANCE;
 }
Beispiel #2
0
 /**
  * Singleton Pattern, Unique Instance of This
  */
 public static function getInstance()
 {
     if (static::$__INSTANCE === null) {
         if (!extension_loaded("pcntl") && (bool) ini_get("enable_dl")) {
             dl("pcntl.so");
         }
         if (!function_exists('pcntl_signal')) {
             $msg = "****** PCNTL EXTENSION NOT LOADED. KILLING THIS PROCESS COULD CAUSE UNPREDICTABLE ERRORS ******";
             Log::doLog($msg);
             static::_TimeStampMsg($msg . "\n");
         } else {
             Log::doLog('registering signal handlers');
             static::_TimeStampMsg('registering signal handlers\\n');
             pcntl_signal(SIGTERM, array(get_called_class(), 'sigSwitch'));
             pcntl_signal(SIGINT, array(get_called_class(), 'sigSwitch'));
             pcntl_signal(SIGHUP, array(get_called_class(), 'sigSwitch'));
             $msg = str_pad(" Signal Handler Installed ", 50, "-", STR_PAD_BOTH);
             Log::doLog($msg);
             static::_TimeStampMsg("{$msg}\n");
         }
         static::$__INSTANCE = new static();
     }
     return static::$__INSTANCE;
 }