Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18832725
D11288.id27121.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D11288.id27121.diff
View Options
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
@@ -10,12 +10,22 @@
pht(
'Start the notifications server in the foreground and print large '.
'volumes of diagnostic information to the console.'))
- ->setArguments(array());
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'client-host',
+ 'param' => 'hostname',
+ 'help' => pht('Hostname to bind to for the client server.'),
+ ),
+ ));
}
public function execute(PhutilArgumentParser $args) {
- $this->willLaunch(true);
- return $this->launch(true);
+ $this->setDebug(true);
+ $this->setClientHost($args->getArg('client-host'));
+
+ $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
@@ -7,10 +7,19 @@
$this
->setName('restart')
->setSynopsis(pht('Stop, then start the notifications server.'))
- ->setArguments(array());
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'client-host',
+ 'param' => 'hostname',
+ 'help' => pht('Hostname to bind to for the client server.'),
+ ),
+ ));
}
public function execute(PhutilArgumentParser $args) {
+ $this->setClientHost($args->getArg('client-host'));
+
$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
@@ -7,10 +7,18 @@
$this
->setName('start')
->setSynopsis(pht('Start the notifications server.'))
- ->setArguments(array());
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'client-host',
+ 'param' => 'hostname',
+ 'help' => pht('Hostname to bind to for the client server.'),
+ ),
+ ));
}
public function execute(PhutilArgumentParser $args) {
+ $this->setClientHost($args->getArg('client-host'));
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,9 @@
abstract class PhabricatorAphlictManagementWorkflow
extends PhabricatorManagementWorkflow {
+ private $debug = false;
+ private $clientHost;
+
final public function getPIDPath() {
return PhabricatorEnv::getEnvConfig('notification.pidfile');
}
@@ -27,6 +30,14 @@
exit(1);
}
+ protected final function setDebug($debug) {
+ $this->debug = $debug;
+ }
+
+ protected final function setClientHost($client_host) {
+ $this->clientHost = $client_host;
+ }
+
public static function requireExtensions() {
self::mustHaveExtension('pcntl');
self::mustHaveExtension('posix');
@@ -50,7 +61,7 @@
}
}
- final protected function willLaunch($debug = false) {
+ final protected function willLaunch() {
$console = PhutilConsole::getConsole();
$pid = $this->getPID();
@@ -70,14 +81,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 +98,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 +111,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 +123,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 +139,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 +152,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
Details
Attached
Mime Type
text/plain
Expires
Oct 26 2025, 10:47 PM (10 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8785142
Default Alt Text
D11288.id27121.diff (8 KB)
Attached To
Mode
D11288: Allow the Aphlict server to bind to localhost
Attached
Detach File
Event Timeline
Log In to Comment