当前位置: 首页>>代码示例>>PHP>>正文


PHP ExecFuture::setStderrSizeLimit方法代码示例

本文整理汇总了PHP中ExecFuture::setStderrSizeLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecFuture::setStderrSizeLimit方法的具体用法?PHP ExecFuture::setStderrSizeLimit怎么用?PHP ExecFuture::setStderrSizeLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExecFuture的用法示例。


在下文中一共展示了ExecFuture::setStderrSizeLimit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: configureFuture

 protected function configureFuture(ExecFuture $future)
 {
     if ($this->getTimeout()) {
         $future->setTimeout($this->getTimeout());
     }
     if ($this->getByteLimit()) {
         $future->setStdoutSizeLimit($this->getByteLimit());
         $future->setStderrSizeLimit($this->getByteLimit());
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:10,代码来源:DiffusionRawDiffQuery.php

示例2: loadChangesetsForCommit

 public function loadChangesetsForCommit($identifier)
 {
     $byte_limit = HeraldCommitAdapter::getEnormousByteLimit();
     $time_limit = HeraldCommitAdapter::getEnormousTimeLimit();
     $vcs = $this->getRepository()->getVersionControlSystem();
     switch ($vcs) {
         case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
         case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
             // For git and hg, we can use normal commands.
             $drequest = DiffusionRequest::newFromDictionary(array('repository' => $this->getRepository(), 'user' => $this->getViewer(), 'commit' => $identifier));
             $raw_diff = DiffusionRawDiffQuery::newFromDiffusionRequest($drequest)->setTimeout($time_limit)->setByteLimit($byte_limit)->setLinesOfContext(0)->loadRawDiff();
             break;
         case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
             // TODO: This diff has 3 lines of context, which produces slightly
             // incorrect "added file content" and "removed file content" results.
             // This may also choke on binaries, but "svnlook diff" does not support
             // the "--diff-cmd" flag.
             // For subversion, we need to use `svnlook`.
             $future = new ExecFuture('svnlook diff -t %s %s', $this->subversionTransaction, $this->subversionRepository);
             $future->setTimeout($time_limit);
             $future->setStdoutSizeLimit($byte_limit);
             $future->setStderrSizeLimit($byte_limit);
             list($raw_diff) = $future->resolvex();
             break;
         default:
             throw new Exception(pht("Unknown VCS '%s!'", $vcs));
     }
     if (strlen($raw_diff) >= $byte_limit) {
         throw new Exception(pht('The raw text of this change is enormous (larger than %d ' . 'bytes). Herald can not process it.', $byte_limit));
     }
     if (!strlen($raw_diff)) {
         // If the commit is actually empty, just return no changesets.
         return array();
     }
     $parser = new ArcanistDiffParser();
     $changes = $parser->parseDiff($raw_diff);
     $diff = DifferentialDiff::newEphemeralFromRawChanges($changes);
     return $diff->getChangesets();
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:39,代码来源:DiffusionCommitHookEngine.php

示例3: run

 public function run()
 {
     if ($this->shouldRunSilently()) {
         echo "Running daemon '{$this->daemon}' silently. Use '--trace' or " . "'--verbose' to produce debugging output.\n";
     }
     $root = phutil_get_library_root('phutil');
     $root = dirname($root);
     $exec_dir = $root . '/scripts/daemon/exec/';
     // NOTE: PHP implements proc_open() by running 'sh -c'. On most systems this
     // is bash, but on Ubuntu it's dash. When you proc_open() using bash, you
     // get one new process (the command you ran). When you proc_open() using
     // dash, you get two new processes: the command you ran and a parent
     // "dash -c" (or "sh -c") process. This means that the child process's PID
     // is actually the 'dash' PID, not the command's PID. To avoid this, use
     // 'exec' to replace the shell process with the real process; without this,
     // the child will call posix_getppid(), be given the pid of the 'sh -c'
     // process, and send it SIGUSR1 to keepalive which will terminate it
     // immediately. We also won't be able to do process group management because
     // the shell process won't properly posix_setsid() so the pgid of the child
     // won't be meaningful.
     // Format the exec command, which looks something like:
     //
     //   exec ./exec_daemon DaemonName --trace -- --no-discovery
     $argv = array();
     $argv[] = csprintf('exec ./exec_daemon.php %s', $this->daemon);
     foreach ($this->argv as $k => $arg) {
         $argv[] = csprintf('%s', $arg);
     }
     $argv[] = '--';
     foreach ($this->moreArgs as $k => $arg) {
         $argv[] = csprintf('%s', $arg);
     }
     $command = implode(' ', $argv);
     while (true) {
         $this->logMessage('INIT', 'Starting process.');
         $future = new ExecFuture('%C', $command);
         $future->setCWD($exec_dir);
         $future->setStdoutSizeLimit($this->captureBufferSize);
         $future->setStderrSizeLimit($this->captureBufferSize);
         $this->deadline = time() + $this->deadlineTimeout;
         $this->heartbeat = time() + self::HEARTBEAT_WAIT;
         $future->isReady();
         $this->childPID = $future->getPID();
         do {
             do {
                 if ($this->traceMemory) {
                     $memuse = number_format(memory_get_usage() / 1024, 1);
                     $this->logMessage('RAMS', 'Overseer Memory Usage: ' . $memuse . ' KB');
                 }
                 // We need a shortish timeout here so we can run the tick handler
                 // frequently in order to process signals.
                 $result = $future->resolve(1);
                 list($stdout, $stderr) = $future->read();
                 $stdout = trim($stdout);
                 $stderr = trim($stderr);
                 if (strlen($stdout)) {
                     $this->logMessage('STDO', $stdout);
                 }
                 if (strlen($stderr)) {
                     $this->logMessage('STDE', $stderr);
                 }
                 $future->discardBuffers();
                 if ($result !== null) {
                     list($err) = $result;
                     if ($err) {
                         $this->logMessage('FAIL', 'Process exited with error ' . $err . '.', $err);
                     } else {
                         $this->logMessage('DONE', 'Process exited successfully.');
                     }
                     break 2;
                 }
                 if ($this->heartbeat < time()) {
                     $this->heartbeat = time() + self::HEARTBEAT_WAIT;
                     $this->dispatchEvent(self::EVENT_DID_HEARTBEAT);
                 }
             } while (time() < $this->deadline);
             $this->logMessage('HANG', 'Hang detected. Restarting process.');
             $this->annihilateProcessGroup();
         } while (false);
         if ($this->inGracefulShutdown) {
             // If we just exited because of a graceful shutdown, break now.
             break;
         }
         $this->logMessage('WAIT', 'Waiting to restart process.');
         sleep(self::RESTART_WAIT);
         if ($this->inGracefulShutdown) {
             // If we were awakend by a graceful shutdown, break now.
             break;
         }
     }
     // This is a clean exit after a graceful shutdown.
     $this->dispatchEvent(self::EVENT_WILL_EXIT);
     exit(0);
 }
开发者ID:lsubra,项目名称:libphutil,代码行数:94,代码来源:PhutilDaemonOverseer.php

示例4: run

 public function run()
 {
     if ($this->shouldRunSilently()) {
         echo "Running daemon '{$this->daemon}' silently. Use '--trace' or " . "'--verbose' to produce debugging output.\n";
     }
     $root = phutil_get_library_root('phutil');
     $root = dirname($root);
     $exec_dir = $root . '/scripts/daemon/exec/';
     // NOTE: PHP implements proc_open() by running 'sh -c'. On most systems this
     // is bash, but on Ubuntu it's dash. When you proc_open() using bash, you
     // get one new process (the command you ran). When you proc_open() using
     // dash, you get two new processes: the command you ran and a parent
     // "dash -c" (or "sh -c") process. This means that the child process's PID
     // is actually the 'dash' PID, not the command's PID. To avoid this, use
     // 'exec' to replace the shell process with the real process; without this,
     // the child will call posix_getppid(), be given the pid of the 'sh -c'
     // process, and send it SIGUSR1 to keepalive which will terminate it
     // immediately. We also won't be able to do process group management because
     // the shell process won't properly posix_setsid() so the pgid of the child
     // won't be meaningful.
     $exec_daemon = './exec_daemon.php';
     $argv = $this->argv;
     array_unshift($argv, 'exec', $exec_daemon, $this->daemon);
     foreach ($argv as $k => $arg) {
         $argv[$k] = escapeshellarg($arg);
     }
     $command = implode(' ', $argv);
     while (true) {
         $this->logMessage('INIT', 'Starting process.');
         $future = new ExecFuture($command);
         $future->setCWD($exec_dir);
         $future->setStdoutSizeLimit($this->captureBufferSize);
         $future->setStderrSizeLimit($this->captureBufferSize);
         $this->deadline = time() + $this->deadlineTimeout;
         $this->heartbeat = time() + self::HEARTBEAT_WAIT;
         $future->isReady();
         $this->childPID = $future->getPID();
         do {
             do {
                 if ($this->traceMemory) {
                     $memuse = number_format(memory_get_usage() / 1024, 1);
                     $this->logMessage('RAMS', 'Overseer Memory Usage: ' . $memuse . ' KB');
                 }
                 // We need a shortish timeout here so we can run the tick handler
                 // frequently in order to process signals.
                 $result = $future->resolve(1);
                 list($stdout, $stderr) = $future->read();
                 $stdout = trim($stdout);
                 $stderr = trim($stderr);
                 if (strlen($stdout)) {
                     $this->logMessage('STDO', $stdout, $stdout);
                 }
                 if (strlen($stderr)) {
                     $this->logMessage('STDE', $stderr, $stderr);
                 }
                 $future->discardBuffers();
                 if ($result !== null) {
                     list($err) = $result;
                     if ($err) {
                         $this->logMessage('FAIL', 'Process exited with error ' . $err . '.', $err);
                     } else {
                         $this->logMessage('DONE', 'Process exited successfully.');
                     }
                     break 2;
                 }
                 if ($this->heartbeat < time()) {
                     $this->heartbeat = time() + self::HEARTBEAT_WAIT;
                     if ($this->conduitURI) {
                         try {
                             $this->conduit = new ConduitClient($this->conduitURI);
                             $this->conduit->callMethodSynchronous('daemon.setstatus', array('daemonLogID' => $this->daemonLogID, 'status' => 'run'));
                         } catch (Exception $ex) {
                         }
                     }
                 }
             } while (time() < $this->deadline);
             $this->logMessage('HANG', 'Hang detected. Restarting process.');
             $this->annihilateProcessGroup();
         } while (false);
         $this->logMessage('WAIT', 'Waiting to restart process.');
         sleep($this->restartDelay);
     }
 }
开发者ID:rwray,项目名称:libphutil,代码行数:83,代码来源:PhutilDaemonOverseer.php


注:本文中的ExecFuture::setStderrSizeLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。