1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 15:00:58 +01:00

Merge pull request #176 from nexeck/master

D3149: The Log and PID directory should be separable in the config file
This commit is contained in:
Evan Priestley 2012-08-05 06:07:09 -07:00
commit 2e78b56f70
3 changed files with 22 additions and 10 deletions

View file

@ -1095,7 +1095,10 @@ return array(
// Directory that phd (the Phabricator daemon control script) should use to // Directory that phd (the Phabricator daemon control script) should use to
// track running daemons. // track running daemons.
'phd.pid-directory' => '/var/tmp/phd', 'phd.pid-directory' => '/var/tmp/phd/pid',
// Directory that the Phabricator daemons should use to store the log file
'phd.log-directory' => '/var/tmp/phd/log',
// Number of "TaskMaster" daemons that "phd start" should start. You can // Number of "TaskMaster" daemons that "phd start" should start. You can
// raise this if you have a task backlog, or explicitly launch more with // raise this if you have a task backlog, or explicitly launch more with

View file

@ -225,7 +225,7 @@ function will_launch($control, $with_logs = true) {
echo "Staging launch...\n"; echo "Staging launch...\n";
$control->pingConduit(); $control->pingConduit();
if ($with_logs) { if ($with_logs) {
$log_dir = $control->getControlDirectory('log').'/daemons.log'; $log_dir = $control->getLogDirectory().'/daemons.log';
echo "NOTE: Logs will appear in '{$log_dir}'.\n\n"; echo "NOTE: Logs will appear in '{$log_dir}'.\n\n";
} }
} }

View file

@ -254,11 +254,11 @@ EOHELP
$flags[] = csprintf('--conduit-uri=%s', PhabricatorEnv::getURI('/api/')); $flags[] = csprintf('--conduit-uri=%s', PhabricatorEnv::getURI('/api/'));
if (!$debug) { if (!$debug) {
$log_dir = $this->getControlDirectory('log').'/daemons.log'; $log_file = $this->getLogDirectory().'/daemons.log';
$flags[] = csprintf('--log=%s', $log_dir); $flags[] = csprintf('--log=%s', $log_file);
} }
$pid_dir = $this->getControlDirectory('pid'); $pid_dir = $this->getPIDDirectory();
// TODO: This should be a much better user experience. // TODO: This should be a much better user experience.
Filesystem::assertExists($pid_dir); Filesystem::assertExists($pid_dir);
@ -295,21 +295,30 @@ EOHELP
return; return;
} }
public function getControlDirectory($dir) { private function getControlDirectory($path) {
$path = PhabricatorEnv::getEnvConfig('phd.pid-directory').'/'.$dir;
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(
"phd requires the directory '{$path}' to exist, but it does not ". "phd requires the directory '{$path}' to exist, but it does not ".
"exist and could not be created. Create this directory or update ". "exist and could not be created. Create this directory or update ".
"'phd.pid-directory' in your configuration to point to an existing ". "'phd.pid-directory' / 'phd.log-directory' in your configuration ".
"directory."); "to point to an existing directory.");
} }
} }
return $path; return $path;
} }
public function getPIDDirectory() {
$path = PhabricatorEnv::getEnvConfig('phd.pid-directory');
return $this->getControlDirectory($path);
}
public function getLogDirectory() {
$path = PhabricatorEnv::getEnvConfig('phd.log-directory');
return $this->getControlDirectory($path);
}
protected function loadAvailableDaemonClasses() { protected function loadAvailableDaemonClasses() {
$loader = new PhutilSymbolLoader(); $loader = new PhutilSymbolLoader();
return $loader return $loader
@ -321,7 +330,7 @@ EOHELP
public function loadRunningDaemons() { public function loadRunningDaemons() {
$results = array(); $results = array();
$pid_dir = $this->getControlDirectory('pid'); $pid_dir = $this->getPIDDirectory();
$pid_files = Filesystem::listDirectory($pid_dir); $pid_files = Filesystem::listDirectory($pid_dir);
if (!$pid_files) { if (!$pid_files) {
return $results; return $results;