mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
Fix module imports in Aphlict server
Summary: This was broken in D11383. Basically, I had the `ws` module installed globally whilst testing, but the changes made do not work if the `ws` module is installed locally (i.e. in the `./support/aphlict/server/node_modules` directory). After poking around, it seems that this is due to the sandboxing that is done by `JX.require`. A quick fix is to just //not// use `JX.require`, although you may have a better idea? The error that is occurring is as follows: ``` <<< UNCAUGHT EXCEPTION! >>> Error: Cannot find module 'ws' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at extra.require (/usr/src/phabricator/webroot/rsrc/externals/javelin/core/init_node.js:48:16) at /usr/src/phabricator/support/aphlict/server/lib/AphlictClientServer.js:10:17 at Script.(anonymous function) [as runInNewContext] (vm.js:41:22) at Object.JX.require (/usr/src/phabricator/webroot/rsrc/externals/javelin/core/init_node.js:58:6) at Object.<anonymous> (/usr/src/phabricator/support/aphlict/server/aphlict_server.js:102:4) at Module._compile (module.js:456:26) >>> Server exited! ``` Test Plan: Now able to start the Aphlict server. Reviewers: joshuaspence Reviewed By: joshuaspence Subscribers: Korvin, epriestley Maniphest Tasks: T6987 Differential Revision: https://secure.phabricator.com/D11425
This commit is contained in:
parent
94730a1a43
commit
4636833f3d
8 changed files with 25 additions and 30 deletions
|
@ -167,7 +167,7 @@ return array(
|
||||||
'rsrc/externals/javelin/core/__tests__/stratcom.js' => '88bf7313',
|
'rsrc/externals/javelin/core/__tests__/stratcom.js' => '88bf7313',
|
||||||
'rsrc/externals/javelin/core/__tests__/util.js' => 'e251703d',
|
'rsrc/externals/javelin/core/__tests__/util.js' => 'e251703d',
|
||||||
'rsrc/externals/javelin/core/init.js' => '76e1fd61',
|
'rsrc/externals/javelin/core/init.js' => '76e1fd61',
|
||||||
'rsrc/externals/javelin/core/init_node.js' => 'd7dde471',
|
'rsrc/externals/javelin/core/init_node.js' => '7212f324',
|
||||||
'rsrc/externals/javelin/core/install.js' => '05270951',
|
'rsrc/externals/javelin/core/install.js' => '05270951',
|
||||||
'rsrc/externals/javelin/core/util.js' => 'bdcfee9e',
|
'rsrc/externals/javelin/core/util.js' => 'bdcfee9e',
|
||||||
'rsrc/externals/javelin/docs/Base.js' => '74676256',
|
'rsrc/externals/javelin/docs/Base.js' => '74676256',
|
||||||
|
|
|
@ -4,9 +4,6 @@ var https = require('https');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
JX.require('lib/AphlictListenerList', __dirname);
|
|
||||||
JX.require('lib/AphlictLog', __dirname);
|
|
||||||
|
|
||||||
function parse_command_line_arguments(argv) {
|
function parse_command_line_arguments(argv) {
|
||||||
var config = {
|
var config = {
|
||||||
'client-port': 22280,
|
'client-port': 22280,
|
||||||
|
@ -37,6 +34,8 @@ function parse_command_line_arguments(argv) {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require('./lib/AphlictLog');
|
||||||
|
|
||||||
var debug = new JX.AphlictLog()
|
var debug = new JX.AphlictLog()
|
||||||
.addConsole(console);
|
.addConsole(console);
|
||||||
|
|
||||||
|
@ -71,6 +70,12 @@ try {
|
||||||
'documentation for instructions. ' + ex.toString());
|
'documentation for instructions. ' + ex.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Require these only after checking for the "ws" module, since they
|
||||||
|
// depend on it.
|
||||||
|
|
||||||
|
require('./lib/AphlictAdminServer');
|
||||||
|
require('./lib/AphlictClientServer');
|
||||||
|
|
||||||
var ssl_config = {
|
var ssl_config = {
|
||||||
enabled: (config['ssl-key'] || config['ssl-cert'])
|
enabled: (config['ssl-key'] || config['ssl-cert'])
|
||||||
};
|
};
|
||||||
|
@ -94,9 +99,6 @@ if (config.test) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
JX.require('lib/AphlictAdminServer', __dirname);
|
|
||||||
JX.require('lib/AphlictClientServer', __dirname);
|
|
||||||
|
|
||||||
var server;
|
var server;
|
||||||
if (ssl_config.enabled) {
|
if (ssl_config.enabled) {
|
||||||
server = https.createServer({
|
server = https.createServer({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var JX = require('javelin').JX;
|
var JX = require('./javelin').JX;
|
||||||
|
|
||||||
JX.require('AphlictListenerList', __dirname);
|
require('./AphlictListenerList');
|
||||||
|
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
var JX = require('javelin').JX;
|
var JX = require('./javelin').JX;
|
||||||
|
|
||||||
JX.require('AphlictListenerList', __dirname);
|
require('./AphlictListenerList');
|
||||||
JX.require('AphlictLog', __dirname);
|
require('./AphlictLog');
|
||||||
|
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var WebSocket = require('ws');
|
var WebSocket = require('ws');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var JX = require('javelin').JX;
|
var JX = require('./javelin').JX;
|
||||||
|
|
||||||
JX.install('AphlictListener', {
|
JX.install('AphlictListener', {
|
||||||
construct: function(id, socket) {
|
construct: function(id, socket) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var JX = require('javelin').JX;
|
var JX = require('./javelin').JX;
|
||||||
JX.require('AphlictListener', __dirname);
|
|
||||||
|
require('./AphlictListener');
|
||||||
|
|
||||||
JX.install('AphlictListenerList', {
|
JX.install('AphlictListenerList', {
|
||||||
construct: function() {
|
construct: function() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var JX = require('javelin').JX;
|
var JX = require('./javelin').JX;
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
20
webroot/rsrc/externals/javelin/core/init_node.js
vendored
20
webroot/rsrc/externals/javelin/core/init_node.js
vendored
|
@ -23,9 +23,8 @@ JX.onload = function(func) {
|
||||||
func();
|
func();
|
||||||
};
|
};
|
||||||
|
|
||||||
JX.require = function(thing, relative) {
|
JX.require = function(thing) {
|
||||||
relative = relative || __dirname + '/..';
|
var path = __dirname + '/../' + thing + '.js';
|
||||||
var path = relative + '/' + thing + '.js';
|
|
||||||
var content = fs.readFileSync(path);
|
var content = fs.readFileSync(path);
|
||||||
var dir = pathModule.dirname(path);
|
var dir = pathModule.dirname(path);
|
||||||
|
|
||||||
|
@ -37,17 +36,10 @@ JX.require = function(thing, relative) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var extra = {
|
var extra = {
|
||||||
JX : this,
|
JX: this,
|
||||||
__DEV__ : 0,
|
__DEV__: 0,
|
||||||
window : {},
|
window: {},
|
||||||
__dirname : dir,
|
__dirname: dir
|
||||||
require : function(thing) {
|
|
||||||
if (thing == 'javelin') {
|
|
||||||
return require(dir + '/' + thing);
|
|
||||||
} else {
|
|
||||||
return require(thing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (k in extra) {
|
for (k in extra) {
|
||||||
|
|
Loading…
Reference in a new issue