kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Use ES6 let, change default port to 3000
rodzic
6e3624d5f8
commit
15bb8962d2
|
@ -14,7 +14,7 @@
|
||||||
* @property {number} port Port to launch server on
|
* @property {number} port Port to launch server on
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var config = {};
|
let config = {};
|
||||||
|
|
||||||
// Instance name - default name for this configuration (will be server process name)
|
// Instance name - default name for this configuration (will be server process name)
|
||||||
config.instance = 'node-OpenDroneMap';
|
config.instance = 'node-OpenDroneMap';
|
||||||
|
@ -28,7 +28,7 @@ config.logger.maxFiles = 10; // Max number of log files kept
|
||||||
config.logger.logDirectory = ''; // Set this to a full path to a directory - if not set logs will be written to the application directory.
|
config.logger.logDirectory = ''; // Set this to a full path to a directory - if not set logs will be written to the application directory.
|
||||||
|
|
||||||
// Server port
|
// Server port
|
||||||
config.port = process.env.PORT || 8081;
|
config.port = process.env.PORT || 3000;
|
||||||
// process.env.PORT is what AWS Elastic Beanstalk defines
|
// process.env.PORT is what AWS Elastic Beanstalk defines
|
||||||
// on IBM bluemix use config.port = process.env.VCAP_APP_PORT || 8081;
|
// on IBM bluemix use config.port = process.env.VCAP_APP_PORT || 8081;
|
||||||
|
|
||||||
|
|
6
index.js
6
index.js
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var config = require('./config.js')
|
let config = require('./config.js')
|
||||||
|
|
||||||
let logger = require('winston');
|
let logger = require('winston');
|
||||||
let fs = require('fs');
|
let fs = require('fs');
|
||||||
|
@ -34,7 +34,7 @@ let morgan = require('morgan');
|
||||||
|
|
||||||
// Set up logging
|
// Set up logging
|
||||||
// Configure custom File transport to write plain text messages
|
// Configure custom File transport to write plain text messages
|
||||||
var logPath = ( config.logger.logDirectory ? config.logger.logDirectory : __dirname );
|
let logPath = ( config.logger.logDirectory ? config.logger.logDirectory : __dirname );
|
||||||
// Check that log file directory can be written to
|
// Check that log file directory can be written to
|
||||||
try {
|
try {
|
||||||
fs.accessSync(logPath, fs.W_OK);
|
fs.accessSync(logPath, fs.W_OK);
|
||||||
|
@ -56,7 +56,7 @@ logger
|
||||||
// Console transport is no use to us when running as a daemon
|
// Console transport is no use to us when running as a daemon
|
||||||
.remove(logger.transports.Console);
|
.remove(logger.transports.Console);
|
||||||
|
|
||||||
var winstonStream = {
|
let winstonStream = {
|
||||||
write: function(message, encoding){
|
write: function(message, encoding){
|
||||||
logger.info(message.slice(0, -1));
|
logger.info(message.slice(0, -1));
|
||||||
}
|
}
|
||||||
|
|
16
libs/Task.js
16
libs/Task.js
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Node-OpenDroneMap Node.js App and REST API to access OpenDroneMap.
|
Node-OpenDroneMap Node.js App and REST API to access OpenDroneMap.
|
||||||
Copyright (C) 2016 Node-OpenDroneMap Contributors
|
Copyright (C) 2016 Node-OpenDroneMap Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -57,7 +57,7 @@ module.exports = class Task{
|
||||||
for (let k in taskJson){
|
for (let k in taskJson){
|
||||||
task[k] = taskJson[k];
|
task[k] = taskJson[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tasks that were running should be put back to QUEUED state
|
// Tasks that were running should be put back to QUEUED state
|
||||||
if (task.status.code === statusCodes.RUNNING){
|
if (task.status.code === statusCodes.RUNNING){
|
||||||
task.status.code = statusCodes.QUEUED;
|
task.status.code = statusCodes.QUEUED;
|
||||||
|
@ -94,13 +94,13 @@ module.exports = class Task{
|
||||||
this.status = {
|
this.status = {
|
||||||
code: code
|
code: code
|
||||||
};
|
};
|
||||||
for (var k in extra){
|
for (let k in extra){
|
||||||
this.status[k] = extra[k];
|
this.status[k] = extra[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProcessingTime(resetTime){
|
updateProcessingTime(resetTime){
|
||||||
this.processingTime = resetTime ?
|
this.processingTime = resetTime ?
|
||||||
-1 :
|
-1 :
|
||||||
new Date().getTime() - this.dateCreated;
|
new Date().getTime() - this.dateCreated;
|
||||||
}
|
}
|
||||||
|
@ -135,12 +135,12 @@ module.exports = class Task{
|
||||||
if (this.status.code !== statusCodes.CANCELED){
|
if (this.status.code !== statusCodes.CANCELED){
|
||||||
let wasRunning = this.status.code === statusCodes.RUNNING;
|
let wasRunning = this.status.code === statusCodes.RUNNING;
|
||||||
this.setStatus(statusCodes.CANCELED);
|
this.setStatus(statusCodes.CANCELED);
|
||||||
|
|
||||||
if (wasRunning && this.runnerProcess){
|
if (wasRunning && this.runnerProcess){
|
||||||
// TODO: this does guarantee that
|
// TODO: this does guarantee that
|
||||||
// the process will immediately terminate.
|
// the process will immediately terminate.
|
||||||
// In fact, often times ODM will continue running for a while
|
// In fact, often times ODM will continue running for a while
|
||||||
// This might need to be fixed on ODM's end.
|
// This might need to be fixed on ODM's end.
|
||||||
this.runnerProcess.kill('SIGINT');
|
this.runnerProcess.kill('SIGINT');
|
||||||
this.runnerProcess = null;
|
this.runnerProcess = null;
|
||||||
}
|
}
|
||||||
|
@ -262,4 +262,4 @@ module.exports = class Task{
|
||||||
options: this.options
|
options: this.options
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -207,7 +207,7 @@ module.exports = class TaskManager{
|
||||||
// Serializes the list of tasks and saves it
|
// Serializes the list of tasks and saves it
|
||||||
// to disk
|
// to disk
|
||||||
dumpTaskList(done){
|
dumpTaskList(done){
|
||||||
var output = [];
|
let output = [];
|
||||||
|
|
||||||
for (let uuid in this.tasks){
|
for (let uuid in this.tasks){
|
||||||
output.push(this.tasks[uuid].serialize());
|
output.push(this.tasks[uuid].serialize());
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var uuid = require('node-uuid');
|
let uuid = require('node-uuid');
|
||||||
|
|
||||||
module.exports = function (options) {
|
module.exports = function (options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
@ -14,4 +14,4 @@ module.exports = function (options) {
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue