@@ -254,11 +254,11 @@ public function launchDaemon($daemon, array $argv, $debug = false) {
254
254
$ flags [] = csprintf ('--conduit-uri=%s ' , PhabricatorEnv::getURI ('/api/ ' ));
255
255
256
256
if (!$ debug ) {
257
- $ log_dir = $ this ->getControlDirectory ( ' log ' ).'/daemons.log ' ;
258
- $ flags [] = csprintf ('--log=%s ' , $ log_dir );
257
+ $ log_file = $ this ->getLogDirectory ( ).'/daemons.log ' ;
258
+ $ flags [] = csprintf ('--log=%s ' , $ log_file );
259
259
}
260
260
261
- $ pid_dir = $ this ->getControlDirectory ( ' pid ' );
261
+ $ pid_dir = $ this ->getPIDDirectory ( );
262
262
263
263
// TODO: This should be a much better user experience.
264
264
Filesystem::assertExists ($ pid_dir );
@@ -295,21 +295,30 @@ public static function ignoreSignal($signo) {
295
295
return ;
296
296
}
297
297
298
- public function getControlDirectory ($ dir ) {
299
- $ path = PhabricatorEnv::getEnvConfig ('phd.pid-directory ' ).'/ ' .$ dir ;
298
+ private function getControlDirectory ($ path ) {
300
299
if (!Filesystem::pathExists ($ path )) {
301
300
list ($ err ) = exec_manual ('mkdir -p %s ' , $ path );
302
301
if ($ err ) {
303
302
throw new Exception (
304
303
"phd requires the directory ' {$ path }' to exist, but it does not " .
305
304
"exist and could not be created. Create this directory or update " .
306
- "'phd.pid-directory' in your configuration to point to an existing " .
307
- "directory. " );
305
+ "'phd.pid-directory' / 'phd.log-directory' in your configuration " .
306
+ "to point to an existing directory. " );
308
307
}
309
308
}
310
309
return $ path ;
311
310
}
312
311
312
+ public function getPIDDirectory () {
313
+ $ path = PhabricatorEnv::getEnvConfig ('phd.pid-directory ' );
314
+ return $ this ->getControlDirectory ($ path );
315
+ }
316
+
317
+ public function getLogDirectory () {
318
+ $ path = PhabricatorEnv::getEnvConfig ('phd.log-directory ' );
319
+ return $ this ->getControlDirectory ($ path );
320
+ }
321
+
313
322
protected function loadAvailableDaemonClasses () {
314
323
$ loader = new PhutilSymbolLoader ();
315
324
return $ loader
@@ -321,7 +330,7 @@ protected function loadAvailableDaemonClasses() {
321
330
public function loadRunningDaemons () {
322
331
$ results = array ();
323
332
324
- $ pid_dir = $ this ->getControlDirectory ( ' pid ' );
333
+ $ pid_dir = $ this ->getPIDDirectory ( );
325
334
$ pid_files = Filesystem::listDirectory ($ pid_dir );
326
335
if (!$ pid_files ) {
327
336
return $ results ;
0 commit comments