mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +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:
commit
2e78b56f70
3 changed files with 22 additions and 10 deletions
|
@ -1095,7 +1095,10 @@ return array(
|
|||
|
||||
// Directory that phd (the Phabricator daemon control script) should use to
|
||||
// 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
|
||||
// raise this if you have a task backlog, or explicitly launch more with
|
||||
|
|
|
@ -225,7 +225,7 @@ function will_launch($control, $with_logs = true) {
|
|||
echo "Staging launch...\n";
|
||||
$control->pingConduit();
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,11 +254,11 @@ EOHELP
|
|||
$flags[] = csprintf('--conduit-uri=%s', PhabricatorEnv::getURI('/api/'));
|
||||
|
||||
if (!$debug) {
|
||||
$log_dir = $this->getControlDirectory('log').'/daemons.log';
|
||||
$flags[] = csprintf('--log=%s', $log_dir);
|
||||
$log_file = $this->getLogDirectory().'/daemons.log';
|
||||
$flags[] = csprintf('--log=%s', $log_file);
|
||||
}
|
||||
|
||||
$pid_dir = $this->getControlDirectory('pid');
|
||||
$pid_dir = $this->getPIDDirectory();
|
||||
|
||||
// TODO: This should be a much better user experience.
|
||||
Filesystem::assertExists($pid_dir);
|
||||
|
@ -295,21 +295,30 @@ EOHELP
|
|||
return;
|
||||
}
|
||||
|
||||
public function getControlDirectory($dir) {
|
||||
$path = PhabricatorEnv::getEnvConfig('phd.pid-directory').'/'.$dir;
|
||||
private function getControlDirectory($path) {
|
||||
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.");
|
||||
"'phd.pid-directory' / 'phd.log-directory' in your configuration ".
|
||||
"to point to an existing directory.");
|
||||
}
|
||||
}
|
||||
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() {
|
||||
$loader = new PhutilSymbolLoader();
|
||||
return $loader
|
||||
|
@ -321,7 +330,7 @@ EOHELP
|
|||
public function loadRunningDaemons() {
|
||||
$results = array();
|
||||
|
||||
$pid_dir = $this->getControlDirectory('pid');
|
||||
$pid_dir = $this->getPIDDirectory();
|
||||
$pid_files = Filesystem::listDirectory($pid_dir);
|
||||
if (!$pid_files) {
|
||||
return $results;
|
||||
|
|
Loading…
Reference in a new issue