kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Code cleanup
rodzic
6e56c31ab1
commit
032e20f390
4
index.js
4
index.js
|
@ -159,7 +159,7 @@ app.get('/getOptions', (req, res) => {
|
||||||
|
|
||||||
let gracefulShutdown = done => {
|
let gracefulShutdown = done => {
|
||||||
async.series([
|
async.series([
|
||||||
cb => { taskManager.dumpTaskList(cb); },
|
cb => taskManager.dumpTaskList(cb),
|
||||||
cb => {
|
cb => {
|
||||||
console.log("Closing server");
|
console.log("Closing server");
|
||||||
server.close();
|
server.close();
|
||||||
|
@ -180,7 +180,7 @@ let taskManager;
|
||||||
let server;
|
let server;
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
cb => { taskManager = new TaskManager(cb); },
|
cb => taskManager = new TaskManager(cb),
|
||||||
cb => { server = app.listen(3000, err => {
|
cb => { server = app.listen(3000, err => {
|
||||||
if (!err) console.log('Server has started on port 3000');
|
if (!err) console.log('Server has started on port 3000');
|
||||||
cb(err);
|
cb(err);
|
||||||
|
|
|
@ -33,8 +33,8 @@ module.exports = class TaskManager{
|
||||||
this.runningQueue = [];
|
this.runningQueue = [];
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
cb => { this.restoreTaskListFromDump(cb); },
|
cb => this.restoreTaskListFromDump(cb),
|
||||||
cb => { this.removeOldTasks(cb); },
|
cb => this.removeOldTasks(cb),
|
||||||
cb => {
|
cb => {
|
||||||
this.processNextTask();
|
this.processNextTask();
|
||||||
cb();
|
cb();
|
||||||
|
@ -136,9 +136,7 @@ module.exports = class TaskManager{
|
||||||
removeFromRunningQueue(task){
|
removeFromRunningQueue(task){
|
||||||
assert(task.constructor.name === "Task", "Must be a Task object");
|
assert(task.constructor.name === "Task", "Must be a Task object");
|
||||||
|
|
||||||
this.runningQueue = this.runningQueue.filter(t => {
|
this.runningQueue = this.runningQueue.filter(t => t !== task);
|
||||||
return t !== task;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addNew(task){
|
addNew(task){
|
||||||
|
|
|
@ -170,7 +170,7 @@ module.exports = {
|
||||||
function checkDomain(domain, value){
|
function checkDomain(domain, value){
|
||||||
let dc, matches;
|
let dc, matches;
|
||||||
|
|
||||||
if (dc = domainChecks.find(dc => { return matches = domain.match(dc.regex); })){
|
if (dc = domainChecks.find(dc => matches = domain.match(dc.regex))){
|
||||||
if (!dc.validate(matches, value)) throw new Error(`Invalid value ${value} (out of range)`);
|
if (!dc.validate(matches, value)) throw new Error(`Invalid value ${value} (out of range)`);
|
||||||
}else{
|
}else{
|
||||||
throw new Error(`Domain value cannot be handled: '${domain}' : '${value}'`);
|
throw new Error(`Domain value cannot be handled: '${domain}' : '${value}'`);
|
||||||
|
@ -181,7 +181,7 @@ module.exports = {
|
||||||
for (let odmOption of odmOptions){
|
for (let odmOption of odmOptions){
|
||||||
// Was this option selected by the user?
|
// Was this option selected by the user?
|
||||||
let opt;
|
let opt;
|
||||||
if (opt = options.find(o => { return o.name === odmOption.name; })){
|
if (opt = options.find(o => o.name === odmOption.name)){
|
||||||
try{
|
try{
|
||||||
// Convert to proper data type
|
// Convert to proper data type
|
||||||
let value = typeConversion[odmOption.type](opt.value);
|
let value = typeConversion[odmOption.type](opt.value);
|
||||||
|
|
|
@ -31,17 +31,11 @@ module.exports = {
|
||||||
], {cwd: ODM_PATH});
|
], {cwd: ODM_PATH});
|
||||||
|
|
||||||
childProcess
|
childProcess
|
||||||
.on('exit', (code, signal) => {
|
.on('exit', (code, signal) => done(null, code, signal))
|
||||||
done(null, code, signal);
|
|
||||||
})
|
|
||||||
.on('error', done);
|
.on('error', done);
|
||||||
|
|
||||||
childProcess.stdout.on('data', chunk => {
|
childProcess.stdout.on('data', chunk => outputReceived(chunk.toString()));
|
||||||
outputReceived(chunk.toString());
|
childProcess.stderr.on('data', chunk => outputReceived(chunk.toString()));
|
||||||
});
|
|
||||||
childProcess.stderr.on('data', chunk => {
|
|
||||||
outputReceived(chunk.toString());
|
|
||||||
});
|
|
||||||
|
|
||||||
return childProcess;
|
return childProcess;
|
||||||
},
|
},
|
||||||
|
@ -63,9 +57,7 @@ module.exports = {
|
||||||
})
|
})
|
||||||
.on('error', done);
|
.on('error', done);
|
||||||
|
|
||||||
let processOutput = chunk => {
|
let processOutput = chunk => output.push(chunk.toString());
|
||||||
output.push(chunk.toString());
|
|
||||||
};
|
|
||||||
|
|
||||||
childProcess.stdout.on('data', processOutput);
|
childProcess.stdout.on('data', processOutput);
|
||||||
childProcess.stderr.on('data', processOutput);
|
childProcess.stderr.on('data', processOutput);
|
||||||
|
|
Ładowanie…
Reference in New Issue