kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Added ability to change task options during restart
rodzic
c7413f04b9
commit
afb7469c75
|
@ -224,7 +224,7 @@ _required_|UUID of the task|string|
|
||||||
=== POST /task/restart
|
=== POST /task/restart
|
||||||
|
|
||||||
==== Description
|
==== Description
|
||||||
Restarts a task that was previously canceled or that had failed to process
|
Restarts a task that was previously canceled, that had failed to process or that successfully completed
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
==== Parameters
|
||||||
|
@ -232,6 +232,8 @@ Restarts a task that was previously canceled or that had failed to process
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
||||||
|===
|
|===
|
||||||
|Type|Name|Description|Schema|Default
|
|Type|Name|Description|Schema|Default
|
||||||
|
|*Body*|*options* +
|
||||||
|
_optional_|Serialized JSON string of the options to use for processing, as an array of the format: [{name: option1, value: value1}, {name: option2, value: value2}, …]. For example, [{"name":"cmvs-maxImages","value":"500"},{"name":"time","value":true}]. For a list of all options, call /options. Overrides the previous options set for this task.|string|
|
||||||
|*Body*|*uuid* +
|
|*Body*|*uuid* +
|
||||||
_required_|UUID of the task|string|
|
_required_|UUID of the task|string|
|
||||||
|===
|
|===
|
||||||
|
|
File diff suppressed because one or more lines are too long
23
index.js
23
index.js
|
@ -482,7 +482,7 @@ app.post('/task/remove', uuidCheck, (req, res) => {
|
||||||
/** @swagger
|
/** @swagger
|
||||||
* /task/restart:
|
* /task/restart:
|
||||||
* post:
|
* post:
|
||||||
* description: Restarts a task that was previously canceled or that had failed to process
|
* description: Restarts a task that was previously canceled, that had failed to process or that successfully completed
|
||||||
* parameters:
|
* parameters:
|
||||||
* -
|
* -
|
||||||
* name: uuid
|
* name: uuid
|
||||||
|
@ -491,14 +491,31 @@ app.post('/task/remove', uuidCheck, (req, res) => {
|
||||||
* required: true
|
* required: true
|
||||||
* schema:
|
* schema:
|
||||||
* type: string
|
* type: string
|
||||||
|
* -
|
||||||
|
* name: options
|
||||||
|
* in: body
|
||||||
|
* description: 'Serialized JSON string of the options to use for processing, as an array of the format: [{name: option1, value: value1}, {name: option2, value: value2}, ...]. For example, [{"name":"cmvs-maxImages","value":"500"},{"name":"time","value":true}]. For a list of all options, call /options. Overrides the previous options set for this task.'
|
||||||
|
* required: false
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Command Received
|
* description: Command Received
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/definitions/Response"
|
* $ref: "#/definitions/Response"
|
||||||
*/
|
*/
|
||||||
app.post('/task/restart', uuidCheck, (req, res) => {
|
app.post('/task/restart', uuidCheck, (req, res, next) => {
|
||||||
taskManager.restart(req.body.uuid, successHandler(res));
|
if (req.body.options){
|
||||||
|
odmOptions.filterOptions(req.body.options, (err, options) => {
|
||||||
|
if (err) res.json({ error: err.message });
|
||||||
|
else {
|
||||||
|
req.body.options = options;
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else next();
|
||||||
|
}, (req, res) => {
|
||||||
|
taskManager.restart(req.body.uuid, req.body.options, successHandler(res));
|
||||||
});
|
});
|
||||||
|
|
||||||
/** @swagger
|
/** @swagger
|
||||||
|
|
|
@ -392,12 +392,13 @@ module.exports = class Task{
|
||||||
|
|
||||||
// Re-executes the task (by setting it's state back to QUEUED)
|
// Re-executes the task (by setting it's state back to QUEUED)
|
||||||
// Only tasks that have been canceled, completed or have failed can be restarted.
|
// Only tasks that have been canceled, completed or have failed can be restarted.
|
||||||
restart(cb){
|
restart(options, cb){
|
||||||
if ([statusCodes.CANCELED, statusCodes.FAILED, statusCodes.COMPLETED].indexOf(this.status.code) !== -1){
|
if ([statusCodes.CANCELED, statusCodes.FAILED, statusCodes.COMPLETED].indexOf(this.status.code) !== -1){
|
||||||
this.setStatus(statusCodes.QUEUED);
|
this.setStatus(statusCodes.QUEUED);
|
||||||
this.dateCreated = new Date().getTime();
|
this.dateCreated = new Date().getTime();
|
||||||
this.output = [];
|
this.output = [];
|
||||||
this.stopTrackingProcessingTime(true);
|
this.stopTrackingProcessingTime(true);
|
||||||
|
if (options !== undefined) this.options = options;
|
||||||
cb(null);
|
cb(null);
|
||||||
}else{
|
}else{
|
||||||
cb(new Error("Task cannot be restarted"));
|
cb(new Error("Task cannot be restarted"));
|
||||||
|
|
|
@ -230,10 +230,11 @@ module.exports = class TaskManager{
|
||||||
|
|
||||||
// Restarts (puts back into QUEUED state)
|
// Restarts (puts back into QUEUED state)
|
||||||
// a task that is either in CANCELED or FAILED state.
|
// a task that is either in CANCELED or FAILED state.
|
||||||
restart(uuid, cb){
|
// When options is set, the task's options are overriden
|
||||||
|
restart(uuid, options, cb){
|
||||||
let task = this.find(uuid, cb);
|
let task = this.find(uuid, cb);
|
||||||
if (task){
|
if (task){
|
||||||
task.restart(err => {
|
task.restart(options, err => {
|
||||||
if (!err) this.processNextTask();
|
if (!err) this.processNextTask();
|
||||||
cb(err);
|
cb(err);
|
||||||
});
|
});
|
||||||
|
|
Ładowanie…
Reference in New Issue