diff --git a/scripts/daemon/phabricator_daemon_launcher.php b/scripts/daemon/phabricator_daemon_launcher.php index ef2806d5ba..671be82fef 100755 --- a/scripts/daemon/phabricator_daemon_launcher.php +++ b/scripts/daemon/phabricator_daemon_launcher.php @@ -24,9 +24,6 @@ require_once $root.'/scripts/__init_env__.php'; phutil_require_module('phabricator', 'infrastructure/daemon/control'); $control = new PhabricatorDaemonControl(); -$phd_dir = PhabricatorEnv::getEnvConfig('phd.pid-directory'); -$pid_dir = $phd_dir.'/pid'; - switch (isset($argv[1]) ? $argv[1] : 'help') { case 'list': $err = $control->executeListCommand(); @@ -202,6 +199,3 @@ function phd_load_tracked_repositories() { return $repositories; } - - - diff --git a/src/infrastructure/daemon/control/PhabricatorDaemonControl.php b/src/infrastructure/daemon/control/PhabricatorDaemonControl.php index 48abaa785b..cff0abf72b 100644 --- a/src/infrastructure/daemon/control/PhabricatorDaemonControl.php +++ b/src/infrastructure/daemon/control/PhabricatorDaemonControl.php @@ -216,7 +216,18 @@ EOHELP } protected function getControlDirectory($dir) { - return PhabricatorEnv::getEnvConfig('phd.pid-directory').'/'.$dir; + $path = PhabricatorEnv::getEnvConfig('phd.pid-directory').'/'.$dir; + if (!Filesystem::pathExists($path)) { + list($err) = exec_manual('mkdir -p %s', $path); + if ($err) { + throw new Exception( + "phd requires the directory '{$path}' to exist, but it does not ". + "exist and could not be created. Create this directory or update ". + "'phd.pid-directory' in your configuration to point to an existing ". + "directory."); + } + } + return $path; } protected function loadAvailableDaemonClasses() {