Differential D20608 Diff 49173 src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
| <?php | <?php | ||||
| abstract class PhabricatorDaemonManagementWorkflow | abstract class PhabricatorDaemonManagementWorkflow | ||||
| extends PhabricatorManagementWorkflow { | extends PhabricatorManagementWorkflow { | ||||
| private $runDaemonsAsUser = null; | private $runDaemonsAsUser = null; | ||||
| final protected function loadAvailableDaemonClasses() { | final protected function loadAvailableDaemonClasses() { | ||||
| return id(new PhutilSymbolLoader()) | return id(new PhutilSymbolLoader()) | ||||
| ->setAncestorClass('PhutilDaemon') | ->setAncestorClass('PhutilDaemon') | ||||
| ->setConcreteOnly(true) | ->setConcreteOnly(true) | ||||
| ->selectSymbolsWithoutLoading(); | ->selectSymbolsWithoutLoading(); | ||||
| } | } | ||||
| final protected function getPIDDirectory() { | |||||
| $path = PhabricatorEnv::getEnvConfig('phd.pid-directory'); | |||||
| return $this->getControlDirectory($path); | |||||
| } | |||||
| final protected function getLogDirectory() { | final protected function getLogDirectory() { | ||||
| $path = PhabricatorEnv::getEnvConfig('phd.log-directory'); | $path = PhabricatorEnv::getEnvConfig('phd.log-directory'); | ||||
| return $this->getControlDirectory($path); | return $this->getControlDirectory($path); | ||||
| } | } | ||||
| private function getControlDirectory($path) { | private function getControlDirectory($path) { | ||||
| if (!Filesystem::pathExists($path)) { | if (!Filesystem::pathExists($path)) { | ||||
| list($err) = exec_manual('mkdir -p %s', $path); | list($err) = exec_manual('mkdir -p %s', $path); | ||||
| if ($err) { | if ($err) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| "%s requires the directory '%s' to exist, but it does not exist ". | "%s requires the directory '%s' to exist, but it does not exist ". | ||||
| "and could not be created. Create this directory or update ". | "and could not be created. Create this directory or update ". | ||||
| "'%s' / '%s' in your configuration to point to an existing ". | "'%s' in your configuration to point to an existing ". | ||||
| "directory.", | "directory.", | ||||
| 'phd', | 'phd', | ||||
| $path, | $path, | ||||
| 'phd.pid-directory', | |||||
| 'phd.log-directory')); | 'phd.log-directory')); | ||||
| } | } | ||||
| } | } | ||||
| return $path; | return $path; | ||||
| } | } | ||||
| private function findDaemonClass($substring) { | private function findDaemonClass($substring) { | ||||
| $symbols = $this->loadAvailableDaemonClasses(); | $symbols = $this->loadAvailableDaemonClasses(); | ||||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | final protected function launchDaemons( | ||||
| if (!$debug) { | if (!$debug) { | ||||
| $config['daemonize'] = true; | $config['daemonize'] = true; | ||||
| } | } | ||||
| if (!$debug) { | if (!$debug) { | ||||
| $config['log'] = $this->getLogDirectory().'/daemons.log'; | $config['log'] = $this->getLogDirectory().'/daemons.log'; | ||||
| } | } | ||||
| $pid_dir = $this->getPIDDirectory(); | |||||
| // TODO: This should be a much better user experience. | |||||
amckinley: Mission accomplished! | |||||
| Filesystem::assertExists($pid_dir); | |||||
| Filesystem::assertIsDirectory($pid_dir); | |||||
| Filesystem::assertWritable($pid_dir); | |||||
| $config['piddir'] = $pid_dir; | |||||
| $config['daemons'] = $daemons; | $config['daemons'] = $daemons; | ||||
| $command = csprintf('./phd-daemon %Ls', $flags); | $command = csprintf('./phd-daemon %Ls', $flags); | ||||
| $phabricator_root = dirname(phutil_get_library_root('phabricator')); | $phabricator_root = dirname(phutil_get_library_root('phabricator')); | ||||
| $daemon_script_dir = $phabricator_root.'/scripts/daemon/'; | $daemon_script_dir = $phabricator_root.'/scripts/daemon/'; | ||||
| if ($debug) { | if ($debug) { | ||||
| ▲ Show 20 Lines • Show All 461 Lines • Show Last 20 Lines | |||||
Mission accomplished!