From 1f09e05c683c8df77460672e6c17444a0edb1c29 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Thu, 15 Jan 2015 06:54:25 +1100 Subject: [PATCH] Automatically create the Aphlict log directory Summary: Fixes T6944. Attempt to automatically create the log directory for the Aphlict server. If the directory can't be created, throw a helpful exception. Test Plan: # Set `notification.log` to `/var/log/aphlict/aphlict.log`. # Ran `./bin/aphlict debug` and saw an exception (because the user doesn't have permissions to create the `/var/log/aphlict` directory). # Ran `sudo chmod 777 /var/log`. # Ran `./bin/aphlict debug` and saw the `/var/log/aphlict` directory created. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T6944 Differential Revision: https://secure.phabricator.com/D11387 --- .../PhabricatorAphlictManagementWorkflow.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php b/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php index 34616b18cd..03e03ae254 100644 --- a/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php +++ b/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php @@ -34,6 +34,22 @@ abstract class PhabricatorAphlictManagementWorkflow return PhabricatorEnv::getEnvConfig('notification.pidfile'); } + final public function getLogPath() { + $path = PhabricatorEnv::getEnvConfig('notification.log'); + + try { + $dir = dirname($path); + Filesystem::createDirectory($dir, 0755, true); + } catch (FilesystemException $ex) { + throw new Exception( + pht( + "Failed to create '%s'. You should manually create this directory.", + $dir)); + } + + return $path; + } + final public function getPID() { $pid = null; if (Filesystem::pathExists($this->getPIDPath())) { @@ -128,7 +144,7 @@ abstract class PhabricatorAphlictManagementWorkflow $client_uri = PhabricatorEnv::getEnvConfig('notification.client-uri'); $client_uri = new PhutilURI($client_uri); - $log = PhabricatorEnv::getEnvConfig('notification.log'); + $log = $this->getLogPath(); $server_argv = array(); $server_argv[] = '--client-port='.coalesce(