Skip to content

Commit

Permalink
Merge pull request #75 from OpenDroneMap/aligned-to-nodeodm
Browse files Browse the repository at this point in the history
Aligned to nodeodm part1
  • Loading branch information
kikislater authored Sep 15, 2024
2 parents abcf941 + 28e9ab7 commit 293b533
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
7 changes: 4 additions & 3 deletions config-default.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"instance": "node-MicMac-DroneMapper",
"instance": "node-MicMac",
"odm_path": "/code",

"logger": {
Expand All @@ -9,13 +9,14 @@
"logDirectory": ""
},

"port": 3000,
"port": "auto",
"deamon": false,
"parallelQueueProcessing": 2,
"cleanupTasksAfter": 2880,
"test": false,
"testSkipOrthophotos": false,
"testSkipDems": false,
"token": "",
"authorizedIps": [],
"maxImages": ""
}
}
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ config.logger.maxFileSize = fromConfigFile("logger.maxFileSize", 1024 * 1024 * 1
config.logger.maxFiles = fromConfigFile("logger.maxFiles", 10); // Max number of log files kept
config.logger.logDirectory = fromConfigFile("logger.logDirectory", ''); // Set this to a full path to a directory - if not set logs will be written to the application directory.

config.port = parseInt(argv.port || argv.p || fromConfigFile("port", process.env.PORT || 3000));
config.port = (argv.port || argv.p || fromConfigFile("port", process.env.PORT || "auto"));
config.deamon = argv.deamonize || argv.d || fromConfigFile("daemon", false);
config.parallelQueueProcessing = parseInt(argv.parallel_queue_processing || argv.q || fromConfigFile("parallelQueueProcessing", 2));
config.cleanupTasksAfter = parseInt(argv.cleanup_tasks_after || fromConfigFile("cleanupTasksAfter", 2880));
Expand Down
2 changes: 1 addition & 1 deletion dm/odm_options.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"--version": {
"action": "version",
"version": "DroneMapper MicMac",
"version": "Node MicMac",
"help": "Displays version number and exits. "
}
}
27 changes: 23 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,29 @@ let commands = [
taskManager = TaskManager.singleton();
},
cb => {
server = app.listen(config.port, err => {
if (!err) logger.info('Server has started on port ' + String(config.port));
cb(err);
});
const startServer = (port, cb) => {
server = app.listen(parseInt(port), (err) => {
if (!err) logger.info('Server has started on port ' + String(port));
cb(err);
});
server.on("error", cb);
};

const tryStartServer = (port, cb) => {
startServer(port, (err) => {
if (err && err.code === 'EADDRINUSE' && port < 5000){
tryStartServer(port + 1, cb);
}else cb(err);
});
};

if (Number.isInteger(parseInt(config.port))){
startServer(config.port, cb);
}else if (config.port === "auto"){
tryStartServer(3000, cb);
}else{
cb(new Error(`Invalid port: ${config.port}`));
}
}
];

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"opendronemap"
],
"author": "Piero Toffanin",
"license": "GPL-3.0",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/OpenDroneMap/NodeODM/issues"
},
Expand All @@ -36,10 +36,10 @@
"request": "^2.88.0",
"rimraf": "^2.6.2",
"swagger-jsdoc": "^3.2.6",
"systeminformation": "5.6.4",
"systeminformation": "3.42.0",
"tree-kill": "^1.2.1",
"uuid": "^3.3.2",
"winston": "^2.2.0"
"winston": "^3.3.3"
},
"devDependencies": {
"grunt": "^1.0.3",
Expand Down

0 comments on commit 293b533

Please sign in to comment.