예제 #1
0
파일: Stop.php 프로젝트: Grummfy/Central
 /**
  * The entry method.
  *
  * @return  void
  */
 public function main()
 {
     $run = 'hoa://Data/Variable/Run';
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 'r':
                 $run = $v;
                 break;
             case 'h':
             case '?':
                 return $this->usage();
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
         }
     }
     $this->parser->listInputs($workerId);
     if (null === $workerId) {
         return $this->usage();
     }
     $run = resolve($run);
     Core::getInstance()->initialize(['protocol.Data/Variable/Run' => "\r" . $run . DS]);
     $password = $this->readPassword('Password: ');
     $sw = new Worker\Backend\Shared($workerId, $password);
     $sw->stop();
     return;
 }
예제 #2
0
파일: Suite.php 프로젝트: Grummfy/Central
 public function __construct()
 {
     $this->setMethodPrefix('case');
     parent::__construct();
     $protocol = Core::getInstance()->getProtocol();
     $protocol['Test'] = new Core\Protocol\Generic('Test', null);
     $protocol['Test']['Vfs'] = new Test\Protocol\Vfs();
     return;
 }
예제 #3
0
 * @license    New BSD License
 */
class _Protocol extends Core\Protocol
{
    /**
     * Component's name.
     *
     * @var string
     */
    protected $_name = 'Registry';
    /**
     * ID of the component.
     *
     * @param   string  $id    ID of the component.
     * @return  mixed
     */
    public function reachId($id)
    {
        return Registry::get($id);
    }
}
/**
 * Flex entity.
 */
Core\Consistency::flexEntity('Hoa\\Registry\\Registry');
/**
 * Add the hoa://Library/Registry component. Should be use to reach/get an entry
 * in the \Hoa\Registry, e.g.: resolve('hoa://Library/Registry#AnID').
 */
$protocol = Core::getInstance()->getProtocol();
$protocol['Library'][] = new _Protocol();
예제 #4
0
 /**
  * Singleton to manage a library family.
  *
  * @param   string  $from    Library family's name.
  * @return  void
  */
 private function __construct($from)
 {
     $this->_from = preg_split('#\\s*(,|or)\\s*#', trim($from, '()'));
     $parameters = Core::getInstance()->getParameters();
     $wildcard = $parameters->getFormattedParameter('namespace.prefix.*');
     foreach ($this->_from as $f) {
         $this->setRoot($parameters->getFormattedParameter('namespace.prefix.' . $f) ?: $wildcard, $f);
     }
     return;
 }
예제 #5
0
 * Set the default timezone.
 */
date_default_timezone_set('UTC');
/**
 * Load the autoloader.
 */
$autoloadFile = __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
if (false === file_exists($autoloadFile)) {
    echo 'Autoloader is not found. Did you run `composer install`?', "\n";
    exit(1);
}
$autoloader = (require_once $autoloadFile);
/**
 * Configure hoa:// (basis of katana://).
 */
Core::getInstance()->initialize(['root.application' => __DIR__ . DS, 'root.data' => __DIR__ . DS . 'data' . DS, 'protocol.bin' => '(:%root.application:)' . 'bin' . DS, 'protocol.data' => '(:%root.data:)', 'protocol.data/lib' => "\r" . '(:%root.application:)' . 'vendor' . DS, 'protocol.lib' => '(:%root.application:)' . 'lib' . DS, 'protocol.public' => '(:%root.application:)' . 'public' . DS, 'protocol.resource' => __DIR__ . DS . 'resource' . DS, 'protocol.tests' => '(:%root.application:)' . 'tests' . DS]);
/**
 * Register the katana:// protocol.
 */
stream_wrapper_register(Katana\Protocol::SCHEME, 'Sabre\\Katana\\Protocol');
/**
 * sabre/katana is now defined and set up, let the world knows that.
 */
define('SABRE_KATANA', true);
/**
 * Current version.
 */
define('SABRE_KATANA_VERSION', '0.1.1');
/**
 * Define the prefix.
 */
예제 #6
0
파일: Xyl.php 프로젝트: Grummfy/Central
 /**
  * Destruct XYL object.
  *
  * @return  void
  */
 public function __destruct()
 {
     $protocol = Core::getInstance()->getProtocol();
     unset($protocol['Library']['Xyl[' . $this->_i . ']']);
     return;
 }
예제 #7
0
파일: Status.php 프로젝트: shulard/Worker
 /**
  * The entry method.
  *
  * @return  void
  */
 public function main()
 {
     $run = 'hoa://Data/Variable/Run';
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 'r':
                 $run = $v;
                 break;
             case 'h':
             case '?':
                 return $this->usage();
                 break;
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
         }
     }
     $run = resolve($run);
     Core::getInstance()->initialize(['protocol.Data/Variable/Run' => "\r" . $run . DS]);
     $outi = [['ID', 'PID', 'Socket', 'Uptime', 'Messages', 'Last']];
     $outm = [];
     $now = new \DateTime();
     $t = 0;
     echo Console\Chrome\Text::colorize('Shared worker informations', 'foreground(yellow)'), "\n\n";
     foreach (glob($run . DS . '*.wid') as $wid) {
         $worker = new Worker\Shared(substr(basename($wid), 0, -4));
         $infos = $worker->getInformations();
         $uptime = new \DateTime();
         $uptime->setTimestamp((int) $infos['start']);
         $last = new \DateTime();
         $last->setTimestamp((int) $infos['last_message']);
         $outi[] = [$infos['id'], $infos['pid'], $infos['socket'], $uptime->diff($now)->format('%ad%H:%I:%S'), $infos['messages'], 0 === $infos['last_message'] ? '-' : $last->diff($now)->format('%ad%H:%I:%S')];
         $outm[] = $infos;
         ++$t;
     }
     echo Console\Chrome\Text::columnize($outi, 0, 1, '|'), "\n";
     $max_id = 0;
     $max_peak = 0;
     foreach ($outm as $m) {
         $max_id < strlen($m['id']) and $max_id = strlen($m['id']);
         $max_peak < $m['memory_peak'] and $max_peak = $m['memory_peak'];
     }
     foreach ($outm as $m) {
         $outmm = str_pad($m['id'], $max_id) . '  ';
         $max = (int) ($m['memory_peak'] * 39 / $max_peak);
         $peak = (int) ($m['memory_allocated_peak'] * 40 / $max_peak);
         $memory = (int) ($m['memory_allocated'] * 40 / $max_peak);
         for ($i = 0; $i < $memory - 1; ++$i) {
             $outmm .= Console\Chrome\Text::colorize('|', 'foreground(green)');
         }
         for (; $i < $peak; ++$i) {
             $outmm .= Console\Chrome\Text::colorize('|', 'foreground(yellow)');
         }
         for (; $i < $max; ++$i) {
             $outmm .= ' ';
         }
         $outmm .= Console\Chrome\Text::colorize('|', 'foreground(red)');
         for (++$i; $i < 40; ++$i) {
             $outmm .= ' ';
         }
         $outmm .= '  ' . Console\Chrome\Text::colorize(number_format($m['memory_allocated'] / 1024) . 'Kb', 'foreground(green)') . ' ' . Console\Chrome\Text::colorize(number_format($m['memory_allocated_peak'] / 1024) . 'Kb', 'foreground(yellow)') . ' ' . Console\Chrome\Text::colorize(number_format($m['memory_peak'] / 1024) . 'Kb', 'foreground(red)');
         echo $outmm . "\n";
     }
     echo "\n", $t, ' shared worker', $t > 1 ? 's are' : ' is', ' running.', "\n";
     return;
 }
예제 #8
0
 /**
  * The entry method.
  *
  * @return  int
  */
 public function main()
 {
     $sections = [];
     $mail = null;
     $diagnostic = [];
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 's':
                 $sections = $this->parser->parseSpecialValue($v);
                 break;
             case 'm':
                 $mail = $v;
                 break;
             case 'h':
             case '?':
                 return $this->usage();
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
         }
     }
     $store = function ($sections, $key, $value = null) use(&$diagnostic) {
         if (is_array($key) && null === $value) {
             foreach ($key as $i => $name) {
                 $diagnostic[$sections][$i] = $name;
             }
         } else {
             $diagnostic[$sections][$key] = $value;
         }
         return;
     };
     $store('version', 'php', phpversion());
     $store('version', 'zend_engine', zend_version());
     $store('system', 'platform', php_uname());
     $store('system', 'architecture', true === S_32_BITS ? '32bits' : '64bits');
     $store('system', 'lang', isset($_SERVER['LANG']) ? $_SERVER['LANG'] : 'unknown');
     $store('bin', 'self', $_SERVER['PHP_SELF']);
     $store('bin', 'hoa', Core::getInstance()->getParameters()->getFormattedParameter('root.hoa'));
     $store('bin', 'php_dir', PHP_BINDIR);
     $store('bin', 'php', defined('PHP_BINARY') ? PHP_BINARY : 'unknown');
     foreach (get_loaded_extensions() as $extension) {
         $reflection = new \ReflectionExtension($extension);
         $entry = 'extension-' . strtolower($extension);
         if ('extension-standard' !== $entry && 'extension-core' !== $entry) {
             $entries = [];
             foreach ($reflection->getINIEntries() as $key => $value) {
                 $entries[substr($key, strpos($key, '.') + 1)] = $value;
             }
         } else {
             $entries = $reflection->getINIEntries();
         }
         $store($entry, 'version', $reflection->getVersion() ?: 'unknown');
         $store($entry, $entries);
     }
     if (empty($sections) || in_array('all', $sections)) {
         $ini = $this->arrayToIni($diagnostic);
     } else {
         $handle = [];
         foreach ($sections as $section) {
             if (false === array_key_exists($section, $diagnostic)) {
                 return 1;
             }
             $handle[$section] = $diagnostic[$section];
         }
         $ini = $this->arrayToIni($handle);
     }
     echo $ini, "\n";
     if (null !== $mail) {
         $subject = 'Diagnostic from ' . get_current_user();
         return mail($mail, $subject, $ini) ? 0 : 1;
     }
     return;
 }