1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +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(); $pid = $this->getPID();
if ($pid) { if ($pid) {
$console->writeErr( throw new PhutilArgumentUsageException(
"Unable to start notifications server because it is already ". pht(
"running.\n"); 'Unable to start notifications server because it is already '.
exit(1); 'running. Use `aphlict restart` to restart it.'));
} }
if (posix_getuid() != 0) { if (posix_getuid() != 0) {
$console->writeErr( throw new PhutilArgumentUsageException(
"You must run this script as root; the Aphlict server needs to bind ". pht(
"to privileged ports.\n"); 'You must run this script as root; the Aphlict server needs to bind '.
exit(1); 'to privileged ports.'));
} }
if (!Filesystem::binaryExists('node')) { // This will throw if we can't find an appropriate `node`.
$console->writeErr( $this->getNodeBinary();
"`node` is not in \$PATH. You must install Node.js to run the Aphlict ".
"server.\n");
exit(1);
}
} }
final protected function launch($debug = false) { final protected function launch($debug = false) {
@ -108,7 +104,8 @@ abstract class PhabricatorAphlictManagementWorkflow
} }
$command = csprintf( $command = csprintf(
'node %s %C', '%s %s %C',
$this->getNodeBinary(),
dirname(__FILE__).'/../../../../support/aphlict/server/aphlict_server.js', dirname(__FILE__).'/../../../../support/aphlict/server/aphlict_server.js',
implode(' ', $server_argv)); implode(' ', $server_argv));
@ -201,4 +198,19 @@ abstract class PhabricatorAphlictManagementWorkflow
return 0; 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')) ->setShortName(pht('Notification Server Version'))
->setName(pht('Notification Server Out of Date')) ->setName(pht('Notification Server Out of Date'))
->setMessage($message) ->setMessage($message)
->addCommand('phabricator/ $ sudo ./bin/aphlict start'); ->addCommand('phabricator/ $ sudo ./bin/aphlict restart');
} }
} }