Page MenuHomePhabricator

D11288.diff
No OneTemporary

D11288.diff

diff --git a/src/applications/aphlict/management/PhabricatorAphlictManagementDebugWorkflow.php b/src/applications/aphlict/management/PhabricatorAphlictManagementDebugWorkflow.php
--- a/src/applications/aphlict/management/PhabricatorAphlictManagementDebugWorkflow.php
+++ b/src/applications/aphlict/management/PhabricatorAphlictManagementDebugWorkflow.php
@@ -4,18 +4,21 @@
extends PhabricatorAphlictManagementWorkflow {
public function didConstruct() {
+ parent::didConstruct();
$this
->setName('debug')
->setSynopsis(
pht(
'Start the notifications server in the foreground and print large '.
- 'volumes of diagnostic information to the console.'))
- ->setArguments(array());
+ 'volumes of diagnostic information to the console.'));
}
public function execute(PhutilArgumentParser $args) {
- $this->willLaunch(true);
- return $this->launch(true);
+ parent::execute($args);
+ $this->setDebug(true);
+
+ $this->willLaunch();
+ return $this->launch();
}
}
diff --git a/src/applications/aphlict/management/PhabricatorAphlictManagementRestartWorkflow.php b/src/applications/aphlict/management/PhabricatorAphlictManagementRestartWorkflow.php
--- a/src/applications/aphlict/management/PhabricatorAphlictManagementRestartWorkflow.php
+++ b/src/applications/aphlict/management/PhabricatorAphlictManagementRestartWorkflow.php
@@ -4,13 +4,15 @@
extends PhabricatorAphlictManagementWorkflow {
public function didConstruct() {
+ parent::didConstruct();
$this
->setName('restart')
- ->setSynopsis(pht('Stop, then start the notifications server.'))
- ->setArguments(array());
+ ->setSynopsis(pht('Stop, then start the notifications server.'));
}
public function execute(PhutilArgumentParser $args) {
+ parent::execute($args);
+
$err = $this->executeStopCommand();
if ($err) {
return $err;
diff --git a/src/applications/aphlict/management/PhabricatorAphlictManagementStartWorkflow.php b/src/applications/aphlict/management/PhabricatorAphlictManagementStartWorkflow.php
--- a/src/applications/aphlict/management/PhabricatorAphlictManagementStartWorkflow.php
+++ b/src/applications/aphlict/management/PhabricatorAphlictManagementStartWorkflow.php
@@ -4,13 +4,14 @@
extends PhabricatorAphlictManagementWorkflow {
public function didConstruct() {
+ parent::didConstruct();
$this
->setName('start')
- ->setSynopsis(pht('Start the notifications server.'))
- ->setArguments(array());
+ ->setSynopsis(pht('Start the notifications server.'));
}
public function execute(PhutilArgumentParser $args) {
+ parent::execute($args);
return $this->executeStartCommand();
}
diff --git a/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php b/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
--- a/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
+++ b/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
@@ -3,6 +3,26 @@
abstract class PhabricatorAphlictManagementWorkflow
extends PhabricatorManagementWorkflow {
+ private $debug = false;
+ private $clientHost;
+
+ public function didConstruct() {
+ $this
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'client-host',
+ 'param' => 'hostname',
+ 'help' => pht('Hostname to bind to for the client server.'),
+ ),
+ ));
+ }
+
+ public function execute(PhutilArgumentParser $args) {
+ $this->clientHost = $args->getArg('client-host');
+ return 0;
+ }
+
final public function getPIDPath() {
return PhabricatorEnv::getEnvConfig('notification.pidfile');
}
@@ -27,6 +47,10 @@
exit(1);
}
+ protected final function setDebug($debug) {
+ $this->debug = $debug;
+ }
+
public static function requireExtensions() {
self::mustHaveExtension('pcntl');
self::mustHaveExtension('posix');
@@ -50,7 +74,7 @@
}
}
- final protected function willLaunch($debug = false) {
+ final protected function willLaunch() {
$console = PhutilConsole::getConsole();
$pid = $this->getPID();
@@ -70,14 +94,14 @@
}
// Make sure we can write to the PID file.
- if (!$debug) {
+ if (!$this->debug) {
Filesystem::writeFile($this->getPIDPath(), '');
}
// First, start the server in configuration test mode with --test. This
// will let us error explicitly if there are missing modules, before we
// fork and lose access to the console.
- $test_argv = $this->getServerArgv($debug);
+ $test_argv = $this->getServerArgv();
$test_argv[] = '--test=true';
execx(
@@ -87,7 +111,7 @@
$test_argv);
}
- private function getServerArgv($debug) {
+ private function getServerArgv() {
$ssl_key = PhabricatorEnv::getEnvConfig('notification.ssl-key');
$ssl_cert = PhabricatorEnv::getEnvConfig('notification.ssl-cert');
@@ -100,9 +124,9 @@
$log = PhabricatorEnv::getEnvConfig('notification.log');
$server_argv = array();
- $server_argv[] = '--port='.$client_uri->getPort();
- $server_argv[] = '--admin='.$server_uri->getPort();
- $server_argv[] = '--host='.$server_uri->getDomain();
+ $server_argv[] = '--client-port='.$client_uri->getPort();
+ $server_argv[] = '--admin-port='.$server_uri->getPort();
+ $server_argv[] = '--admin-host='.$server_uri->getDomain();
if ($ssl_key) {
$server_argv[] = '--ssl-key='.$ssl_key;
@@ -112,10 +136,14 @@
$server_argv[] = '--ssl-cert='.$ssl_cert;
}
- if (!$debug) {
+ if (!$this->debug) {
$server_argv[] = '--log='.$log;
}
+ if ($this->clientHost) {
+ $server_argv[] = '--client-host='.$this->clientHost;
+ }
+
return $server_argv;
}
@@ -124,10 +152,10 @@
return $root.'/support/aphlict/server/aphlict_server.js';
}
- final protected function launch($debug = false) {
+ final protected function launch() {
$console = PhutilConsole::getConsole();
- if ($debug) {
+ if ($this->debug) {
$console->writeOut(pht("Starting Aphlict server in foreground...\n"));
} else {
Filesystem::writeFile($this->getPIDPath(), getmypid());
@@ -137,16 +165,16 @@
'%s %s %Ls',
$this->getNodeBinary(),
$this->getAphlictScriptPath(),
- $this->getServerArgv($debug));
+ $this->getServerArgv());
- if (!$debug) {
+ if (!$this->debug) {
declare(ticks = 1);
pcntl_signal(SIGINT, array($this, 'cleanup'));
pcntl_signal(SIGTERM, array($this, 'cleanup'));
}
register_shutdown_function(array($this, 'cleanup'));
- if ($debug) {
+ if ($this->debug) {
$console->writeOut("Launching server:\n\n $ ".$command."\n\n");
$err = phutil_passthru('%C', $command);
diff --git a/support/aphlict/server/aphlict_server.js b/support/aphlict/server/aphlict_server.js
--- a/support/aphlict/server/aphlict_server.js
+++ b/support/aphlict/server/aphlict_server.js
@@ -9,9 +9,10 @@
function parse_command_line_arguments(argv) {
var config = {
- port: 22280,
- admin: 22281,
- host: '127.0.0.1',
+ 'client-port': 22280,
+ 'admin-port': 22281,
+ 'client-host': '0.0.0.0',
+ 'admin-host': '127.0.0.1',
log: '/var/log/aphlict.log',
'ssl-key': null,
'ssl-cert': null,
@@ -30,8 +31,8 @@
config[matches[1]] = matches[2];
}
- config.port = parseInt(config.port, 10);
- config.admin = parseInt(config.admin, 10);
+ config['client-port'] = parseInt(config['client-port'], 10);
+ config['admin-port'] = parseInt(config['admin-port'], 10);
return config;
}
@@ -95,11 +96,16 @@
var https_server = https.createServer({
key: ssl_config.key,
cert: ssl_config.cert
- }, https_discard_handler).listen(config.port);
+ }, https_discard_handler).listen(
+ config['client-port'],
+ config['client-host']);
ws = new WebSocket.Server({server: https_server});
} else {
- ws = new WebSocket.Server({port: config.port});
+ ws = new WebSocket.Server({
+ port: config['client-port'],
+ host: config['client-host'],
+ });
}
ws.on('connection', function(ws) {
@@ -234,6 +240,6 @@
response.writeHead(404, 'Not Found');
response.end();
}
-}).listen(config.admin, config.host);
+}).listen(config['admin-port'], config['admin-host']);
debug.log('Started Server (PID %d)', process.pid);

File Metadata

Mime Type
text/plain
Expires
Mon, May 20, 4:22 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6303268
Default Alt Text
D11288.diff (8 KB)

Event Timeline