Implement NodeJS based server fully replicating osrm-routed

This commit is contained in:
Siarhei Fedartsou
2022-10-23 15:59:51 +02:00
parent 8273e8b0e2
commit 61810b9205
6 changed files with 356 additions and 370 deletions
+14 -9
View File
@@ -185,11 +185,16 @@ class OSRMLoader {
this.loader = {shutdown: (cb) => cb() };
}
if (this.method === 'datastore') {
this.loader.shutdown((err) => {
if (err) return callback(err);
this.loader = this.sharedLoader;
this.sharedLoader.load(inputFile, callback);
});
// shutdown only if we are switching from another loader type
if (this.loader !== this.sharedLoader) {
this.loader.shutdown((err) => {
if (err) return callback(err);
this.loader = this.sharedLoader;
this.sharedLoader.load(inputFile, callback);
});
} else {
this.sharedLoader.load(inputFile, callback);
}
} else if (this.method === 'directly') {
this.loader.shutdown((err) => {
if (err) return callback(err);
@@ -198,12 +203,12 @@ class OSRMLoader {
});
} else if (this.method === 'mmap') {
this.loader.shutdown((err) => {
if (err) return callback(err);
this.loader = this.mmapLoader;
this.mmapLoader.load(inputFile, callback);
if (err) return callback(err);
this.loader = this.mmapLoader;
this.mmapLoader.load(inputFile, callback);
});
} else {
callback(new Error('*** Unknown load method ' + method));
callback(new Error('*** Unknown load method ' + this.method));
}
}