1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

Try nodejs before node when starting notification server

Summary: Fixes T5278. This isn't completely perfect (if you have the other `node` binary, it will fail to detect that it's wrong) but we can maybe wait for that to happen and devise some kind of "is this binary really node?" test if users actually hit it.

Test Plan: Faked things, hit the error; unfaked them and hit the normal flow.

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T5278

Differential Revision: https://secure.phabricator.com/D9419
This commit is contained in:
epriestley 2014-06-07 13:56:23 -07:00
parent bfc594b3eb
commit 39ca090d15
2 changed files with 28 additions and 16 deletions

View file

@ -55,25 +55,21 @@ abstract class PhabricatorAphlictManagementWorkflow
$pid = $this->getPID();
if ($pid) {
$console->writeErr(
"Unable to start notifications server because it is already ".
"running.\n");
exit(1);
throw new PhutilArgumentUsageException(
pht(
'Unable to start notifications server because it is already '.
'running. Use `aphlict restart` to restart it.'));
}
if (posix_getuid() != 0) {
$console->writeErr(
"You must run this script as root; the Aphlict server needs to bind ".
"to privileged ports.\n");
exit(1);
throw new PhutilArgumentUsageException(
pht(
'You must run this script as root; the Aphlict server needs to bind '.
'to privileged ports.'));
}
if (!Filesystem::binaryExists('node')) {
$console->writeErr(
"`node` is not in \$PATH. You must install Node.js to run the Aphlict ".
"server.\n");
exit(1);
}
// This will throw if we can't find an appropriate `node`.
$this->getNodeBinary();
}
final protected function launch($debug = false) {
@ -108,7 +104,8 @@ abstract class PhabricatorAphlictManagementWorkflow
}
$command = csprintf(
'node %s %C',
'%s %s %C',
$this->getNodeBinary(),
dirname(__FILE__).'/../../../../support/aphlict/server/aphlict_server.js',
implode(' ', $server_argv));
@ -201,4 +198,19 @@ abstract class PhabricatorAphlictManagementWorkflow
return 0;
}
private function getNodeBinary() {
if (Filesystem::binaryExists('nodejs')) {
return 'nodejs';
}
if (Filesystem::binaryExists('node')) {
return 'node';
}
throw new PhutilArgumentUsageException(
pht(
'No `nodejs` or `node` binary was found in $PATH. You must install '.
'Node.js to start the Aphlict server.'));
}
}

View file

@ -57,7 +57,7 @@ final class PhabricatorSetupCheckAphlict extends PhabricatorSetupCheck {
->setShortName(pht('Notification Server Version'))
->setName(pht('Notification Server Out of Date'))
->setMessage($message)
->addCommand('phabricator/ $ sudo ./bin/aphlict start');
->addCommand('phabricator/ $ sudo ./bin/aphlict restart');
}
}