From fedbd475b58e7297eb41516f9a81e34937d49015 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 12 Jun 2011 21:11:32 -0700 Subject: [PATCH] Create phd PID directory if it doesn't exist, and give the user a meaningful error message if that doesn't work Summary: This workflow is needlessly bad right now, make it not terrible. Also removed some related, unused code. Test Plan: Ran 'phd launch nice' with no directory and with a failing mkdir command. Reviewed By: toulouse Reviewers: hsb, toulouse, codeblock CC: aran, toulouse Differential Revision: 440 --- scripts/daemon/phabricator_daemon_launcher.php | 6 ------ .../daemon/control/PhabricatorDaemonControl.php | 13 ++++++++++++- 2 files changed, 12 insertions(+), 7 deletions(-) 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() {