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


PHP PhutilArgumentParser::isTraceModeEnabled方法代码示例

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


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

示例1: launchDaemons

 protected final function launchDaemons(array $daemons, $debug, $run_as_current_user = false)
 {
     // Convert any shorthand classnames like "taskmaster" into proper class
     // names.
     foreach ($daemons as $key => $daemon) {
         $class = $this->findDaemonClass($daemon['class']);
         $daemons[$key]['class'] = $class;
     }
     $console = PhutilConsole::getConsole();
     if (!$run_as_current_user) {
         // Check if the script is started as the correct user
         $phd_user = PhabricatorEnv::getEnvConfig('phd.user');
         $current_user = posix_getpwuid(posix_geteuid());
         $current_user = $current_user['name'];
         if ($phd_user && $phd_user != $current_user) {
             if ($debug) {
                 throw new PhutilArgumentUsageException(pht("You are trying to run a daemon as a nonstandard user, " . "and `%s` was not able to `%s` to the correct user. \n" . 'Phabricator is configured to run daemons as "%s", ' . 'but the current user is "%s". ' . "\n" . 'Use `%s` to run as a different user, pass `%s` to ignore this ' . 'warning, or edit `%s` to change the configuration.', 'phd', 'sudo', $phd_user, $current_user, 'sudo', '--as-current-user', 'phd.user'));
             } else {
                 $this->runDaemonsAsUser = $phd_user;
                 $console->writeOut(pht('Starting daemons as %s', $phd_user) . "\n");
             }
         }
     }
     $this->printLaunchingDaemons($daemons, $debug);
     $trace = PhutilArgumentParser::isTraceModeEnabled();
     $flags = array();
     if ($trace || PhabricatorEnv::getEnvConfig('phd.trace')) {
         $flags[] = '--trace';
     }
     if ($debug || PhabricatorEnv::getEnvConfig('phd.verbose')) {
         $flags[] = '--verbose';
     }
     $instance = PhabricatorEnv::getEnvConfig('cluster.instance');
     if ($instance) {
         $flags[] = '-l';
         $flags[] = $instance;
     }
     $config = array();
     if (!$debug) {
         $config['daemonize'] = true;
     }
     if (!$debug) {
         $config['log'] = $this->getLogDirectory() . '/daemons.log';
     }
     $pid_dir = $this->getPIDDirectory();
     // TODO: This should be a much better user experience.
     Filesystem::assertExists($pid_dir);
     Filesystem::assertIsDirectory($pid_dir);
     Filesystem::assertWritable($pid_dir);
     $config['piddir'] = $pid_dir;
     $config['daemons'] = $daemons;
     $command = csprintf('./phd-daemon %Ls', $flags);
     $phabricator_root = dirname(phutil_get_library_root('phabricator'));
     $daemon_script_dir = $phabricator_root . '/scripts/daemon/';
     if ($debug) {
         // Don't terminate when the user sends ^C; it will be sent to the
         // subprocess which will terminate normally.
         pcntl_signal(SIGINT, array(__CLASS__, 'ignoreSignal'));
         echo "\n    phabricator/scripts/daemon/ \$ {$command}\n\n";
         $tempfile = new TempFile('daemon.config');
         Filesystem::writeFile($tempfile, json_encode($config));
         phutil_passthru('(cd %s && exec %C < %s)', $daemon_script_dir, $command, $tempfile);
     } else {
         try {
             $this->executeDaemonLaunchCommand($command, $daemon_script_dir, $config, $this->runDaemonsAsUser);
         } catch (Exception $ex) {
             throw new PhutilArgumentUsageException(pht('Daemons are configured to run as user "%s" in configuration ' . 'option `%s`, but the current user is "%s" and `phd` was unable ' . 'to switch to the correct user with `sudo`. Command output:' . "\n\n" . '%s', $phd_user, 'phd.user', $current_user, $ex->getMessage()));
         }
     }
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:70,代码来源:PhabricatorDaemonManagementWorkflow.php


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