Only listen on 127.0.0.1 (unless overriden by environment) during test runs by default.
This commit is contained in:
parent
649d4ee512
commit
eae9e7fab6
@ -47,7 +47,7 @@ class OSRMBaseLoader{
|
||||
if (err) {
|
||||
if (retryCount < 10) {
|
||||
retryCount++;
|
||||
setTimeout(() => { tryConnect(this.scope.OSRM_PORT, retry); }, 10);
|
||||
setTimeout(() => { tryConnect(this.scope.OSRM_IP, this.scope.OSRM_PORT, retry); }, 10);
|
||||
} else {
|
||||
callback(new Error("Could not connect to osrm-routed after ten retries."));
|
||||
}
|
||||
@ -58,7 +58,7 @@ class OSRMBaseLoader{
|
||||
}
|
||||
};
|
||||
|
||||
tryConnect(this.scope.OSRM_PORT, retry);
|
||||
tryConnect(this.scope.OSRM_IP, this.scope.OSRM_PORT, retry);
|
||||
}
|
||||
};
|
||||
|
||||
@ -77,7 +77,7 @@ class OSRMDirectLoader extends OSRMBaseLoader {
|
||||
osrmUp (callback) {
|
||||
if (this.osrmIsRunning()) return callback(new Error("osrm-routed already running!"));
|
||||
|
||||
const command_arguments = util.format('%s -p %d -a %s', this.inputFile, this.scope.OSRM_PORT, this.scope.ROUTING_ALGORITHM);
|
||||
const command_arguments = util.format('%s -p %d -i %s -a %s', this.inputFile, this.scope.OSRM_PORT, this.scope.OSRM_HOST, this.scope.ROUTING_ALGORITHM);
|
||||
this.child = this.scope.runBin('osrm-routed', command_arguments, this.scope.environment, (err) => {
|
||||
if (err && err.signal !== 'SIGINT') {
|
||||
this.child = null;
|
||||
@ -116,7 +116,7 @@ class OSRMDatastoreLoader extends OSRMBaseLoader {
|
||||
osrmUp (callback) {
|
||||
if (this.osrmIsRunning()) return callback();
|
||||
|
||||
const command_arguments = util.format('--shared-memory=1 -p %d -a %s', this.scope.OSRM_PORT, this.scope.ROUTING_ALGORITHM);
|
||||
const command_arguments = util.format('--shared-memory=1 -i %s -p %d -a %s', this.scope.OSRM_IP, this.scope.OSRM_PORT, this.scope.ROUTING_ALGORITHM);
|
||||
this.child = this.scope.runBin('osrm-routed', command_arguments, this.scope.environment, (err) => {
|
||||
if (err && err.signal !== 'SIGINT') {
|
||||
this.child = null;
|
||||
|
@ -3,8 +3,8 @@
|
||||
const net = require('net');
|
||||
const Timeout = require('node-timeout');
|
||||
|
||||
module.exports = function tryConnect(port, callback) {
|
||||
net.connect({ port: port, host: '127.0.0.1' })
|
||||
module.exports = function tryConnect(host, port, callback) {
|
||||
net.connect({ port: port, host: host })
|
||||
.on('connect', () => { callback(); })
|
||||
.on('error', () => {
|
||||
callback(new Error('Could not connect.'));
|
||||
|
@ -43,7 +43,8 @@ module.exports = function () {
|
||||
this.TIMEZONE_NAMES = this.PLATFORM_WINDOWS ? 'win' : 'iana';
|
||||
|
||||
this.OSRM_PORT = process.env.OSRM_PORT && parseInt(process.env.OSRM_PORT) || 5000;
|
||||
this.HOST = 'http://127.0.0.1:' + this.OSRM_PORT;
|
||||
this.OSRM_IP = process.env.OSRM_IP || '127.0.0.1';
|
||||
this.HOST = `http://${this.OSRM_IP}:${this.OSRM_PORT}`;
|
||||
|
||||
this.OSRM_PROFILE = process.env.OSRM_PROFILE;
|
||||
|
||||
@ -93,7 +94,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
this.verifyOSRMIsNotRunning = (callback) => {
|
||||
tryConnect(this.OSRM_PORT, (err) => {
|
||||
tryConnect(this.OSRM_IP, this.OSRM_PORT, (err) => {
|
||||
if (!err) return callback(new Error('*** osrm-routed is already running.'));
|
||||
else callback();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user