Skip to content

Commit 3006e09

Browse files
wip
1 parent ac1edc7 commit 3006e09

File tree

8 files changed

+1060
-20
lines changed

8 files changed

+1060
-20
lines changed

features/lib/osrm_loader.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const Timeout = require('node-timeout');
66
const tryConnect = require('../lib/try_connect');
77
const errorReason = require('./utils').errorReason;
88

9+
10+
const OSRM_ROUTED = 'node /Users/siarheifedartsou/work/osrm-backend/server/server.js';
11+
//const OSRM_ROUTED = 'osrm-routed';
912
class OSRMBaseLoader{
1013
constructor (scope) {
1114
this.scope = scope;
@@ -45,10 +48,12 @@ class OSRMBaseLoader{
4548
var retryCount = 0;
4649
let retry = (err) => {
4750
if (err) {
48-
if (retryCount < this.scope.OSRM_CONNECTION_RETRIES) {
49-
const timeoutMs = 10 * Math.pow(this.scope.OSRM_CONNECTION_EXP_BACKOFF_COEF, retryCount);
51+
if (retryCount < 10) {
52+
// const timeoutMs = 10 * Math.pow(this.scope.OSRM_CONNECTION_EXP_BACKOFF_COEF, retryCount);
5053
retryCount++;
51-
setTimeout(() => { tryConnect(this.scope.OSRM_IP, this.scope.OSRM_PORT, retry); }, timeoutMs);
54+
setTimeout(() => {
55+
tryConnect(this.scope.OSRM_IP, this.scope.OSRM_PORT, retry);
56+
}, 1000);
5257
} else {
5358
callback(new Error(`Could not connect to osrm-routed after ${this.scope.OSRM_CONNECTION_RETRIES} retries.`));
5459
}
@@ -79,7 +84,7 @@ class OSRMDirectLoader extends OSRMBaseLoader {
7984
if (this.osrmIsRunning()) return callback(new Error("osrm-routed already running!"));
8085

8186
const command_arguments = util.format('%s -p %d -i %s -a %s', this.inputFile, this.scope.OSRM_PORT, this.scope.OSRM_IP, this.scope.ROUTING_ALGORITHM);
82-
this.child = this.scope.runBin('osrm-routed', command_arguments, this.scope.environment, (err) => {
87+
this.child = this.scope.runBin(OSRM_ROUTED, command_arguments, this.scope.environment, (err) => {
8388
if (err && err.signal !== 'SIGINT') {
8489
this.child = null;
8590
throw new Error(util.format('osrm-routed %s: %s', errorReason(err), err.cmd));
@@ -112,7 +117,7 @@ class OSRMmmapLoader extends OSRMBaseLoader {
112117
if (this.osrmIsRunning()) return callback(new Error("osrm-routed already running!"));
113118

114119
const command_arguments = util.format('%s -p %d -i %s -a %s --mmap', this.inputFile, this.scope.OSRM_PORT, this.scope.OSRM_IP, this.scope.ROUTING_ALGORITHM);
115-
this.child = this.scope.runBin('osrm-routed', command_arguments, this.scope.environment, (err) => {
120+
this.child = this.scope.runBin(OSRM_ROUTED, command_arguments, this.scope.environment, (err) => {
116121
if (err && err.signal !== 'SIGINT') {
117122
this.child = null;
118123
throw new Error(util.format('osrm-routed %s: %s', errorReason(err), err.cmd));
@@ -159,7 +164,7 @@ class OSRMDatastoreLoader extends OSRMBaseLoader {
159164
if (this.osrmIsRunning()) return callback();
160165

161166
const command_arguments = util.format('--dataset-name=%s -s -i %s -p %d -a %s', this.scope.DATASET_NAME, this.scope.OSRM_IP, this.scope.OSRM_PORT, this.scope.ROUTING_ALGORITHM);
162-
this.child = this.scope.runBin('osrm-routed', command_arguments, this.scope.environment, (err) => {
167+
this.child = this.scope.runBin(OSRM_ROUTED, command_arguments, this.scope.environment, (err) => {
163168
if (err && err.signal !== 'SIGINT') {
164169
this.child = null;
165170
throw new Error(util.format('osrm-routed %s: %s', errorReason(err), err.cmd));

features/support/hooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = function () {
5151
.defer(rimraf, this.scenarioLogFile)
5252
.awaitAll(callback);
5353
// uncomment to get path to logfile
54-
// console.log(' Writing logging output to ' + this.scenarioLogFile);
54+
console.log(' Writing logging output to ' + this.scenarioLogFile);
5555
});
5656

5757
this.After((scenario, callback) => {

features/support/run.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ module.exports = function () {
3838
};
3939

4040
this.runBin = (bin, options, env, callback) => {
41-
let cmd = path.resolve(util.format('%s/%s%s', this.BIN_PATH, bin, this.EXE));
41+
let cmd = bin;
42+
// if cmd has prefix
43+
4244
let opts = options.split(' ').filter((x) => { return x && x.length > 0; });
45+
if (!cmd.startsWith('node')) {
46+
cmd = path.resolve(util.format('%s/%s%s', this.BIN_PATH, bin, this.EXE));
47+
} else {
48+
opts = ['/Users/siarheifedartsou/work/osrm-backend/server/server.js'].concat(opts);
49+
cmd = '/Users/siarheifedartsou/.nvm/versions/node/v16.13.2/bin/node';
50+
}
4351
let log = fs.createWriteStream(this.scenarioLogFile, {'flags': 'a'});
4452
log.write(util.format('*** running %s %s\n', cmd, options));
4553
// we need to set a large maxbuffer here because we have long running processes like osrm-routed

0 commit comments

Comments
 (0)