Differential D11143 Diff 27053 src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | final protected function willLaunch() { | ||||
$pid = $this->getPID(); | $pid = $this->getPID(); | ||||
if ($pid) { | if ($pid) { | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht( | pht( | ||||
'Unable to start notifications server because it is already '. | 'Unable to start notifications server because it is already '. | ||||
'running. Use `aphlict restart` to restart it.')); | 'running. Use `aphlict restart` to restart it.')); | ||||
} | } | ||||
if (posix_getuid() != 0) { | |||||
throw new PhutilArgumentUsageException( | |||||
pht( | |||||
'You must run this script as root; the Aphlict server needs to bind '. | |||||
'to privileged ports.')); | |||||
} | |||||
// This will throw if we can't find an appropriate `node`. | // This will throw if we can't find an appropriate `node`. | ||||
$this->getNodeBinary(); | $this->getNodeBinary(); | ||||
} | } | ||||
final protected function launch($debug = false) { | final protected function launch($debug = false) { | ||||
$console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
$ssl_key = PhabricatorEnv::getEnvConfig('notification.ssl-key'); | |||||
$ssl_cert = PhabricatorEnv::getEnvConfig('notification.ssl-cert'); | |||||
epriestley: Oh, unused -- I'll remove. | |||||
if ($debug) { | if ($debug) { | ||||
$console->writeOut(pht("Starting Aphlict server in foreground...\n")); | $console->writeOut(pht("Starting Aphlict server in foreground...\n")); | ||||
} else { | } else { | ||||
Filesystem::writeFile($this->getPIDPath(), getmypid()); | Filesystem::writeFile($this->getPIDPath(), getmypid()); | ||||
} | } | ||||
$server_uri = PhabricatorEnv::getEnvConfig('notification.server-uri'); | $server_uri = PhabricatorEnv::getEnvConfig('notification.server-uri'); | ||||
$server_uri = new PhutilURI($server_uri); | $server_uri = new PhutilURI($server_uri); | ||||
$client_uri = PhabricatorEnv::getEnvConfig('notification.client-uri'); | $client_uri = PhabricatorEnv::getEnvConfig('notification.client-uri'); | ||||
$client_uri = new PhutilURI($client_uri); | $client_uri = new PhutilURI($client_uri); | ||||
$user = PhabricatorEnv::getEnvConfig('notification.user'); | |||||
$log = PhabricatorEnv::getEnvConfig('notification.log'); | $log = PhabricatorEnv::getEnvConfig('notification.log'); | ||||
$server_argv = array(); | $server_argv = array(); | ||||
$server_argv[] = csprintf('--port=%s', $client_uri->getPort()); | $server_argv[] = csprintf('--port=%s', $client_uri->getPort()); | ||||
$server_argv[] = csprintf('--admin=%s', $server_uri->getPort()); | $server_argv[] = csprintf('--admin=%s', $server_uri->getPort()); | ||||
$server_argv[] = csprintf('--host=%s', $server_uri->getDomain()); | $server_argv[] = csprintf('--host=%s', $server_uri->getDomain()); | ||||
if ($user) { | if ($ssl_key) { | ||||
$server_argv[] = csprintf('--user=%s', $user); | $server_argv[] = csprintf('--ssl-key=%s', $ssl_key); | ||||
} | |||||
if ($ssl_cert) { | |||||
$server_argv[] = csprintf('--ssl-cert=%s', $ssl_cert); | |||||
} | } | ||||
if (!$debug) { | if (!$debug) { | ||||
$server_argv[] = csprintf('--log=%s', $log); | $server_argv[] = csprintf('--log=%s', $log); | ||||
} | } | ||||
$command = csprintf( | $command = csprintf( | ||||
'%s %s %C', | '%s %s %C', | ||||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |
Oh, unused -- I'll remove.