diff --git a/features/lib/osrm_loader.js b/features/lib/osrm_loader.js index 28ec7ed2b..197e4b5a2 100644 --- a/features/lib/osrm_loader.js +++ b/features/lib/osrm_loader.js @@ -37,6 +37,7 @@ class OSRMBaseLoader{ osrmDown (callback) { if (this.osrmIsRunning()) { this.child.on('exit', (code, signal) => {callback();}); + this.child.down = true; this.child.kill(); } else callback(); } @@ -78,7 +79,7 @@ class OSRMDirectLoader extends OSRMBaseLoader { if (this.osrmIsRunning()) return callback(new Error("osrm-routed already running!")); this.child = this.scope.runBin('osrm-routed', util.format("%s -p %d", this.inputFile, this.scope.OSRM_PORT), this.scope.environment, (err) => { - if (err) { + if (err && !this.child.down) { throw new Error(util.format('osrm-routed %s: %s', errorReason(err), err.cmd)); } }); @@ -115,7 +116,7 @@ class OSRMDatastoreLoader extends OSRMBaseLoader { if (this.osrmIsRunning()) return callback(); this.child = this.scope.runBin('osrm-routed', util.format('--shared-memory=1 -p %d', this.scope.OSRM_PORT), this.scope.environment, (err) => { - if (err) { + if (err && !this.child.down) { throw new Error(util.format('osrm-routed %s: %s', errorReason(err), err.cmd)); } });