mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +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:
parent
bfc594b3eb
commit
39ca090d15
2 changed files with 28 additions and 16 deletions
|
@ -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.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue