@webda/async 2.0.0-beta.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +4 -4
- package/lib/index.js +4 -20
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +4 -0
- package/lib/models.js +4 -9
- package/lib/models.js.map +1 -1
- package/lib/services/asyncjobservice.d.ts +3 -4
- package/lib/services/asyncjobservice.js +160 -182
- package/lib/services/asyncjobservice.js.map +1 -1
- package/lib/services/localrunner.d.ts +4 -3
- package/lib/services/localrunner.js +48 -54
- package/lib/services/localrunner.js.map +1 -1
- package/lib/services/runner.d.ts +3 -3
- package/lib/services/runner.js +6 -12
- package/lib/services/runner.js.map +1 -1
- package/package.json +13 -11
- package/webda.module.json +307 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./models";
|
|
2
|
-
export * from "./services/asyncjobservice";
|
|
3
|
-
export * from "./services/runner";
|
|
4
|
-
export * from "./services/localrunner";
|
|
1
|
+
export * from "./models.js";
|
|
2
|
+
export * from "./services/asyncjobservice.js";
|
|
3
|
+
export * from "./services/runner.js";
|
|
4
|
+
export * from "./services/localrunner.js";
|
package/lib/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./models"), exports);
|
|
18
|
-
__exportStar(require("./services/asyncjobservice"), exports);
|
|
19
|
-
__exportStar(require("./services/runner"), exports);
|
|
20
|
-
__exportStar(require("./services/localrunner"), exports);
|
|
1
|
+
export * from "./models.js";
|
|
2
|
+
export * from "./services/asyncjobservice.js";
|
|
3
|
+
export * from "./services/runner.js";
|
|
4
|
+
export * from "./services/localrunner.js";
|
|
21
5
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
package/lib/models.d.ts
CHANGED
package/lib/models.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncAction = exports.WebdaAsyncAction = void 0;
|
|
4
|
-
const core_1 = require("@webda/core");
|
|
1
|
+
import { CoreModel } from "@webda/core";
|
|
5
2
|
/**
|
|
6
3
|
* Define here a model that can be used along with Store service
|
|
7
4
|
* @WebdaModel
|
|
8
5
|
*/
|
|
9
|
-
class AsyncAction extends
|
|
6
|
+
export default class AsyncAction extends CoreModel {
|
|
10
7
|
}
|
|
11
|
-
exports.default = AsyncAction;
|
|
12
|
-
exports.AsyncAction = AsyncAction;
|
|
13
8
|
/**
|
|
14
9
|
* Define a Webda Async Action
|
|
15
10
|
*/
|
|
16
|
-
class WebdaAsyncAction extends AsyncAction {
|
|
11
|
+
export class WebdaAsyncAction extends AsyncAction {
|
|
17
12
|
}
|
|
18
|
-
|
|
13
|
+
export { AsyncAction };
|
|
19
14
|
//# sourceMappingURL=models.js.map
|
package/lib/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAyBxC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAS;CA2DjD;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,WAAW;CAShD;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CloudBinary, Context, Queue, RequestFilter, Service, ServiceParameters, Store } from "@webda/core";
|
|
2
|
-
import { AsyncAction, AsyncActionQueueItem } from "../models";
|
|
3
|
-
import { Runner } from "./runner";
|
|
2
|
+
import { AsyncAction, AsyncActionQueueItem } from "../models.js";
|
|
3
|
+
import { Runner } from "./runner.js";
|
|
4
4
|
/**
|
|
5
5
|
* Represent a Job information as you will find in env
|
|
6
6
|
*/
|
|
@@ -131,8 +131,7 @@ export default class AsyncJobService<T extends AsyncJobServiceParameters = Async
|
|
|
131
131
|
* @returns
|
|
132
132
|
*/
|
|
133
133
|
getHeaders(jobInfo: JobInfo): {
|
|
134
|
-
|
|
135
|
-
"X-Job-Time": string;
|
|
134
|
+
[key: string]: string;
|
|
136
135
|
};
|
|
137
136
|
/**
|
|
138
137
|
* Wrap async job and call the job status hook
|
|
@@ -1,40 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AsyncJobService = exports.AsyncJobServiceParameters = void 0;
|
|
13
|
-
const core_1 = require("@webda/core");
|
|
14
|
-
const axios_1 = require("axios");
|
|
15
|
-
const crypto = require("crypto");
|
|
16
|
-
const uuid_1 = require("uuid");
|
|
17
|
-
const runner_1 = require("./runner");
|
|
1
|
+
import { Service, ServiceParameters } from "@webda/core";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import * as crypto from "crypto";
|
|
4
|
+
import { v4 as uuidv4 } from "uuid";
|
|
5
|
+
import { Runner } from "./runner.js";
|
|
18
6
|
/**
|
|
19
7
|
* @inheritdoc
|
|
20
8
|
*/
|
|
21
|
-
class AsyncJobServiceParameters extends
|
|
9
|
+
export class AsyncJobServiceParameters extends ServiceParameters {
|
|
22
10
|
constructor(params) {
|
|
23
|
-
var _a, _b, _c, _d;
|
|
24
11
|
super(params);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
this.url ?? (this.url = "/async/jobs");
|
|
13
|
+
this.queue ?? (this.queue = "AsyncActionsQueue");
|
|
14
|
+
this.store ?? (this.store = "AsyncActions");
|
|
15
|
+
this.runners ?? (this.runners = []);
|
|
29
16
|
}
|
|
30
17
|
}
|
|
31
|
-
exports.AsyncJobServiceParameters = AsyncJobServiceParameters;
|
|
32
18
|
/**
|
|
33
19
|
* AsyncService allows you to launch jobs and report status
|
|
34
20
|
*
|
|
35
21
|
* @WebdaModda
|
|
36
22
|
*/
|
|
37
|
-
class AsyncJobService extends
|
|
23
|
+
export default class AsyncJobService extends Service {
|
|
38
24
|
/**
|
|
39
25
|
* @inheritdoc
|
|
40
26
|
*/
|
|
@@ -91,128 +77,119 @@ class AsyncJobService extends core_1.Service {
|
|
|
91
77
|
/**
|
|
92
78
|
* Allow job status report url
|
|
93
79
|
*/
|
|
94
|
-
checkRequest(context) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return false;
|
|
103
|
-
});
|
|
80
|
+
async checkRequest(context) {
|
|
81
|
+
const url = context.getHttpContext().getRelativeUri();
|
|
82
|
+
if (url.startsWith(this.parameters.url)) {
|
|
83
|
+
// Allow status url to be called without other mechanism
|
|
84
|
+
await this.verifyJobRequest(context);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
104
88
|
}
|
|
105
89
|
/**
|
|
106
90
|
*
|
|
107
91
|
* @param context
|
|
108
92
|
* @param action
|
|
109
93
|
*/
|
|
110
|
-
verifyJobRequest(context) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return action;
|
|
132
|
-
});
|
|
94
|
+
async verifyJobRequest(context) {
|
|
95
|
+
const jobId = context.getHttpContext().getUniqueHeader("X-Job-Id");
|
|
96
|
+
if (!jobId) {
|
|
97
|
+
this.log("TRACE", "Require Job Id");
|
|
98
|
+
throw 404;
|
|
99
|
+
}
|
|
100
|
+
const action = await this.store.get(jobId);
|
|
101
|
+
if (!action) {
|
|
102
|
+
this.log("TRACE", `Unknown Job Id '${jobId}'`);
|
|
103
|
+
throw 404;
|
|
104
|
+
}
|
|
105
|
+
const jobTime = context.getHttpContext().getUniqueHeader("X-Job-Time");
|
|
106
|
+
const jobHash = context.getHttpContext().getUniqueHeader("X-Job-Hash");
|
|
107
|
+
// Ensure hash mac is correct
|
|
108
|
+
if (jobHash !== crypto.createHmac(AsyncJobService.HMAC_ALGO, action.__secretKey).update(jobTime).digest("hex")) {
|
|
109
|
+
this.log("TRACE", "Invalid Job HMAC");
|
|
110
|
+
throw 403;
|
|
111
|
+
}
|
|
112
|
+
// Set the context extension
|
|
113
|
+
context.setExtension("asyncJob", action);
|
|
114
|
+
return action;
|
|
133
115
|
}
|
|
134
116
|
/**
|
|
135
117
|
* Status hook for job report
|
|
136
118
|
*
|
|
137
119
|
* Only updates specific fields: status, errorMessage, statusDetails, results, logs (appending)
|
|
138
120
|
*/
|
|
139
|
-
statusHook(context) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
121
|
+
async statusHook(context) {
|
|
122
|
+
const action = await this.verifyJobRequest(context);
|
|
123
|
+
const body = await context.getRequestBody();
|
|
124
|
+
action._lastJobUpdate = Number.parseInt(context.getHttpContext().getUniqueHeader("X-Job-Time")) || 0;
|
|
125
|
+
if (Date.now() - action._lastJobUpdate > 60) {
|
|
126
|
+
action._lastJobUpdate = Date.now();
|
|
127
|
+
}
|
|
128
|
+
if (body.logs && Array.isArray(body.logs)) {
|
|
129
|
+
action.logs.push(...body.logs);
|
|
130
|
+
// Prevent having too much logs
|
|
131
|
+
if (action.logs.length > 100) {
|
|
132
|
+
action.logs = action.logs.slice(-100);
|
|
146
133
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
134
|
+
}
|
|
135
|
+
["status", "errorMessage", "statusDetails", "results"].forEach(k => {
|
|
136
|
+
if (body[k] !== undefined) {
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
action[k] = body[k];
|
|
153
139
|
}
|
|
154
|
-
["status", "errorMessage", "statusDetails", "results"].forEach(k => {
|
|
155
|
-
if (body[k] !== undefined) {
|
|
156
|
-
action[k] = body[k];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
yield this.store.save(action);
|
|
160
|
-
context.write(Object.assign(Object.assign({}, action), { logs: undefined, statusDetails: undefined }));
|
|
161
140
|
});
|
|
141
|
+
await this.store.save(action);
|
|
142
|
+
context.write({ ...action, logs: undefined, statusDetails: undefined });
|
|
162
143
|
}
|
|
163
144
|
/**
|
|
164
145
|
* Worker
|
|
165
146
|
*
|
|
166
147
|
* This will launch actions based on defined runners
|
|
167
148
|
*/
|
|
168
|
-
worker() {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return this.queue.consume(this.handleEvent.bind(this));
|
|
174
|
-
});
|
|
149
|
+
async worker() {
|
|
150
|
+
if (this.runners.length === 0) {
|
|
151
|
+
throw new Error(`AsyncJobService.worker requires runners`);
|
|
152
|
+
}
|
|
153
|
+
return this.queue.consume(this.handleEvent.bind(this));
|
|
175
154
|
}
|
|
176
155
|
/**
|
|
177
156
|
* Handle one event from the queue and launch the job
|
|
178
157
|
* @param event
|
|
179
158
|
*/
|
|
180
|
-
handleEvent(event) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
// Fallback if needed
|
|
191
|
-
if (selectedRunner === undefined && this.parameters.fallbackOnFirst) {
|
|
192
|
-
selectedRunner = this.runners[0];
|
|
193
|
-
}
|
|
194
|
-
if (selectedRunner === undefined) {
|
|
195
|
-
yield this.store.patch({
|
|
196
|
-
uuid: event.uuid,
|
|
197
|
-
status: "ERROR",
|
|
198
|
-
errorMessage: `No runner found for the job`
|
|
199
|
-
});
|
|
200
|
-
return;
|
|
159
|
+
async handleEvent(event) {
|
|
160
|
+
let selectedRunner;
|
|
161
|
+
// Take first to acknowledge the job
|
|
162
|
+
for (let runner of this.runners) {
|
|
163
|
+
if (runner.handleType(event.type)) {
|
|
164
|
+
selectedRunner = runner;
|
|
165
|
+
break;
|
|
201
166
|
}
|
|
202
|
-
|
|
167
|
+
}
|
|
168
|
+
// Fallback if needed
|
|
169
|
+
if (selectedRunner === undefined && this.parameters.fallbackOnFirst) {
|
|
170
|
+
selectedRunner = this.runners[0];
|
|
171
|
+
}
|
|
172
|
+
if (selectedRunner === undefined) {
|
|
173
|
+
await this.store.patch({
|
|
203
174
|
uuid: event.uuid,
|
|
204
|
-
status: "
|
|
205
|
-
|
|
206
|
-
const action = yield this.store.get(event.uuid);
|
|
207
|
-
const info = {
|
|
208
|
-
JOB_SECRET_KEY: action.__secretKey,
|
|
209
|
-
JOB_ID: action.getUuid(),
|
|
210
|
-
JOB_HOOK: this.getWebda().getApiUrl(this.parameters.url),
|
|
211
|
-
JOB_ORCHESTRATOR: this.getName()
|
|
212
|
-
};
|
|
213
|
-
yield action.update({
|
|
214
|
-
job: yield selectedRunner.launchAction(action, info)
|
|
175
|
+
status: "ERROR",
|
|
176
|
+
errorMessage: `No runner found for the job`
|
|
215
177
|
});
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
await this.store.patch({
|
|
181
|
+
uuid: event.uuid,
|
|
182
|
+
status: "STARTING"
|
|
183
|
+
});
|
|
184
|
+
const action = await this.store.get(event.uuid);
|
|
185
|
+
const info = {
|
|
186
|
+
JOB_SECRET_KEY: action.__secretKey,
|
|
187
|
+
JOB_ID: action.getUuid(),
|
|
188
|
+
JOB_HOOK: this.getWebda().getApiUrl(this.parameters.url),
|
|
189
|
+
JOB_ORCHESTRATOR: this.getName()
|
|
190
|
+
};
|
|
191
|
+
await action.patch({
|
|
192
|
+
job: await selectedRunner.launchAction(action, info)
|
|
216
193
|
});
|
|
217
194
|
}
|
|
218
195
|
/**
|
|
@@ -220,17 +197,15 @@ class AsyncJobService extends core_1.Service {
|
|
|
220
197
|
* @param action
|
|
221
198
|
* @returns
|
|
222
199
|
*/
|
|
223
|
-
launchAction(action) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return this.queue.sendMessage({ uuid: action.getUuid(), __secretKey: action.__secretKey, type: action.type });
|
|
233
|
-
});
|
|
200
|
+
async launchAction(action) {
|
|
201
|
+
action.status = "QUEUED";
|
|
202
|
+
action.type = action.constructor.name;
|
|
203
|
+
action.__secretKey = uuidv4();
|
|
204
|
+
await this.store.save(action);
|
|
205
|
+
if (this.parameters.localLaunch) {
|
|
206
|
+
return this.handleEvent({ uuid: action.getUuid(), __secretKey: action.__secretKey, type: action.type });
|
|
207
|
+
}
|
|
208
|
+
return this.queue.sendMessage({ uuid: action.getUuid(), __secretKey: action.__secretKey, type: action.type });
|
|
234
209
|
}
|
|
235
210
|
/**
|
|
236
211
|
* Return headers to request status hook
|
|
@@ -252,70 +227,73 @@ class AsyncJobService extends core_1.Service {
|
|
|
252
227
|
/**
|
|
253
228
|
* Wrap async job and call the job status hook
|
|
254
229
|
*/
|
|
255
|
-
runWebdaAsyncAction(jobInfo
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
230
|
+
async runWebdaAsyncAction(jobInfo) {
|
|
231
|
+
// Get it from environment
|
|
232
|
+
if (jobInfo === undefined) {
|
|
233
|
+
jobInfo = {};
|
|
234
|
+
Object.keys(process.env)
|
|
235
|
+
.filter(k => k.startsWith("JOB_"))
|
|
236
|
+
// @ts-ignore
|
|
237
|
+
.forEach((k) => (jobInfo[k] = process.env[k]));
|
|
238
|
+
}
|
|
239
|
+
// Ensure correct context
|
|
240
|
+
if (!jobInfo.JOB_ORCHESTRATOR || !jobInfo.JOB_ID || !jobInfo.JOB_SECRET_KEY || !jobInfo.JOB_HOOK) {
|
|
241
|
+
throw new Error("Cannot run AsyncAction without context");
|
|
242
|
+
}
|
|
243
|
+
// If we are not the target redirect to the right one
|
|
244
|
+
if (jobInfo.JOB_ORCHESTRATOR !== this.getName()) {
|
|
245
|
+
return this.getService(jobInfo.JOB_ORCHESTRATOR).runWebdaAsyncAction(jobInfo);
|
|
246
|
+
}
|
|
247
|
+
// Get action info by calling the hook
|
|
248
|
+
let action = (await axios.post(jobInfo.JOB_HOOK, {
|
|
249
|
+
agent: {
|
|
250
|
+
...Runner.getAgentInfo(),
|
|
251
|
+
nodeVersion: process.version
|
|
252
|
+
},
|
|
253
|
+
status: "RUNNING"
|
|
254
|
+
}, {
|
|
255
|
+
headers: this.getHeaders(jobInfo)
|
|
256
|
+
})).data;
|
|
257
|
+
let results;
|
|
258
|
+
try {
|
|
259
|
+
// Check it contains the right info
|
|
260
|
+
if (!action.method || !action.serviceName) {
|
|
261
|
+
throw new Error("WebdaAsyncAction must have method and serviceName defined at least");
|
|
263
262
|
}
|
|
264
|
-
//
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
// Call the service[method](...args)
|
|
264
|
+
let service = this.getService(action.serviceName);
|
|
265
|
+
if (!service) {
|
|
266
|
+
throw new Error(`WebdaAsyncAction Service '${action.serviceName}' not found: mismatch app version`);
|
|
267
267
|
}
|
|
268
|
-
//
|
|
269
|
-
if (
|
|
270
|
-
|
|
268
|
+
// @ts-ignore
|
|
269
|
+
if (!service[action.method]) {
|
|
270
|
+
throw new Error(`WebdaAsyncAction Method '${action.method}' not found in service ${action.serviceName}: mismatch app version`);
|
|
271
271
|
}
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
try {
|
|
281
|
-
// Check it contains the right info
|
|
282
|
-
if (!action.method || !action.serviceName) {
|
|
283
|
-
throw new Error("WebdaAsyncAction must have method and serviceName defined at least");
|
|
284
|
-
}
|
|
285
|
-
// Call the service[method](...args)
|
|
286
|
-
let service = this.getService(action.serviceName);
|
|
287
|
-
if (!service) {
|
|
288
|
-
throw new Error(`WebdaAsyncAction Service '${action.serviceName}' not found: mismatch app version`);
|
|
289
|
-
}
|
|
290
|
-
if (!service[action.method]) {
|
|
291
|
-
throw new Error(`WebdaAsyncAction Method '${action.method}' not found in service ${action.serviceName}: mismatch app version`);
|
|
292
|
-
}
|
|
293
|
-
results = yield service[action.method](...action.arguments);
|
|
294
|
-
}
|
|
295
|
-
catch (err) {
|
|
296
|
-
// Job is in error
|
|
297
|
-
yield axios_1.default.post(jobInfo.JOB_HOOK, {
|
|
298
|
-
errorMessage: err.message,
|
|
299
|
-
status: "ERROR"
|
|
300
|
-
}, {
|
|
301
|
-
headers: this.getHeaders(jobInfo)
|
|
302
|
-
});
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
// Update status
|
|
306
|
-
yield axios_1.default.post(jobInfo.JOB_HOOK, {
|
|
307
|
-
results,
|
|
308
|
-
status: "SUCCESS"
|
|
272
|
+
// @ts-ignore
|
|
273
|
+
results = await service[action.method](...(action.arguments || []));
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
// Job is in error
|
|
277
|
+
await axios.post(jobInfo.JOB_HOOK, {
|
|
278
|
+
errorMessage: err?.message,
|
|
279
|
+
status: "ERROR"
|
|
309
280
|
}, {
|
|
310
281
|
headers: this.getHeaders(jobInfo)
|
|
311
282
|
});
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
// Update status
|
|
286
|
+
await axios.post(jobInfo.JOB_HOOK, {
|
|
287
|
+
results,
|
|
288
|
+
status: "SUCCESS"
|
|
289
|
+
}, {
|
|
290
|
+
headers: this.getHeaders(jobInfo)
|
|
312
291
|
});
|
|
313
292
|
}
|
|
314
293
|
}
|
|
315
|
-
exports.default = AsyncJobService;
|
|
316
|
-
exports.AsyncJobService = AsyncJobService;
|
|
317
294
|
/**
|
|
318
295
|
* HMAC Algorithm used for simple auth
|
|
319
296
|
*/
|
|
320
297
|
AsyncJobService.HMAC_ALGO = "sha256";
|
|
298
|
+
export { AsyncJobService };
|
|
321
299
|
//# sourceMappingURL=asyncjobservice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncjobservice.js","sourceRoot":"","sources":["../../src/services/asyncjobservice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"asyncjobservice.js","sourceRoot":"","sources":["../../src/services/asyncjobservice.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,OAAO,EAAE,iBAAiB,EAAS,MAAM,aAAa,CAAC;AAC5G,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAYlC;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,iBAAiB;IA2C9D,YAAY,MAAW;QACrB,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,GAAG,KAAR,IAAI,CAAC,GAAG,GAAK,aAAa,EAAC;QAC3B,IAAI,CAAC,KAAK,KAAV,IAAI,CAAC,KAAK,GAAK,mBAAmB,EAAC;QACnC,IAAI,CAAC,KAAK,KAAV,IAAI,CAAC,KAAK,GAAK,cAAc,EAAC;QAC9B,IAAI,CAAC,OAAO,KAAZ,IAAI,CAAC,OAAO,GAAK,EAAE,EAAC;IACtB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,eACnB,SAAQ,OAAU;IAyBlB;;OAEG;IACH,cAAc,CAAC,MAAW;QACxB,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IACD;;OAEG;IACH,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,yCAAyC,IAAI,CAAC,UAAU,CAAC,KAAK,cAA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,0BAA0B,MAAM,CAAC,WAAW,wBAAwB,CAC9G,CAAC;aACH;YACD,aAAa;YACb,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC;SACrE;QAAC,OAAO,GAAG,EAAE;YACZ,kBAAkB;YAClB,MAAM,KAAK,CAAC,IAAI,CACd,OAAO,CAAC,QAAQ,EAChB;gBACE,YAAY,EAAsB,GAAG,EAAE,OAAO;gBAC9C,MAAM,EAAE,OAAO;aAChB,EACD;gBACE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;aAClC,CACF,CAAC;YACF,OAAO;SACR;QACD,gBAAgB;QAChB,MAAM,KAAK,CAAC,IAAI,CACd,OAAO,CAAC,QAAQ,EAChB;YACE,OAAO;YACP,MAAM,EAAE,SAAS;SAClB,EACD;YACE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;SAClC,CACF,CAAC;IACJ,CAAC;;AAlTD;;GAEG;AACI,yBAAS,GAAW,QAAQ,CAAC;AAkTtC,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ServiceParameters } from "@webda/core";
|
|
3
3
|
import { SpawnOptions } from "child_process";
|
|
4
|
-
import { AsyncAction } from "../models";
|
|
5
|
-
import { JobInfo } from "./asyncjobservice";
|
|
6
|
-
import { AgentInfo, Runner, RunnerParameters } from "./runner";
|
|
4
|
+
import { AsyncAction } from "../models.js";
|
|
5
|
+
import { JobInfo } from "./asyncjobservice.js";
|
|
6
|
+
import { AgentInfo, Runner, RunnerParameters } from "./runner.js";
|
|
7
7
|
export declare class LocalRunnerParameters extends RunnerParameters {
|
|
8
8
|
/**
|
|
9
9
|
* Command to launch
|
|
@@ -42,6 +42,7 @@ export default class LocalRunner<T extends LocalRunnerParameters = LocalRunnerPa
|
|
|
42
42
|
* @inheritdoc
|
|
43
43
|
*/
|
|
44
44
|
loadParameters(params: any): ServiceParameters;
|
|
45
|
+
spawn(command: string, args: string[], options?: SpawnOptions | undefined): import("child_process").ChildProcess;
|
|
45
46
|
/**
|
|
46
47
|
* @inheritdoc
|
|
47
48
|
*/
|
|
@@ -1,76 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LocalRunnerParameters = void 0;
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
|
-
const runner_1 = require("./runner");
|
|
15
|
-
class LocalRunnerParameters extends runner_1.RunnerParameters {
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import { Runner, RunnerParameters } from "./runner.js";
|
|
3
|
+
export class LocalRunnerParameters extends RunnerParameters {
|
|
16
4
|
constructor(params) {
|
|
17
|
-
var _a
|
|
18
|
-
var _c;
|
|
5
|
+
var _a;
|
|
19
6
|
super(params);
|
|
20
|
-
|
|
21
|
-
(
|
|
7
|
+
this.options ?? (this.options = {});
|
|
8
|
+
(_a = this.options).env ?? (_a.env = {});
|
|
22
9
|
}
|
|
23
10
|
}
|
|
24
|
-
exports.LocalRunnerParameters = LocalRunnerParameters;
|
|
25
11
|
/**
|
|
26
12
|
* Run a Job locally on the server by spawning a child process
|
|
27
13
|
*
|
|
28
14
|
* @WebdaModda
|
|
29
15
|
*/
|
|
30
|
-
class LocalRunner extends
|
|
16
|
+
export default class LocalRunner extends Runner {
|
|
31
17
|
/**
|
|
32
18
|
* @inheritdoc
|
|
33
19
|
*/
|
|
34
20
|
loadParameters(params) {
|
|
35
21
|
return new LocalRunnerParameters(params);
|
|
36
22
|
}
|
|
23
|
+
spawn(command, args, options) {
|
|
24
|
+
/* c8 ignore next 2 */
|
|
25
|
+
return spawn(command, args, options);
|
|
26
|
+
}
|
|
37
27
|
/**
|
|
38
28
|
* @inheritdoc
|
|
39
29
|
*/
|
|
40
|
-
launchAction(action, info) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
child.stderr.on("data", data => {
|
|
53
|
-
action.getStore().upsertItemToCollection(action.getUuid(), "logs", data);
|
|
54
|
-
});
|
|
55
|
-
// As this is local just and mostly used for batch auto status it
|
|
56
|
-
yield action.getStore().patch({ uuid: action.getUuid(), status: "RUNNING" });
|
|
57
|
-
child.on("exit", (code) => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
if (code !== 0) {
|
|
59
|
-
this.log("INFO", "Job", action.getUuid(), "errored with", code);
|
|
60
|
-
yield action.getStore().patch({ uuid: action.getUuid(), status: "ERROR" });
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
this.log("INFO", "Job", action.getUuid(), "successful");
|
|
64
|
-
yield action.getStore().patch({ uuid: action.getUuid(), status: "SUCCESS" });
|
|
65
|
-
}
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
agent: runner_1.Runner.getAgentInfo(),
|
|
70
|
-
pid: child.pid
|
|
71
|
-
};
|
|
30
|
+
async launchAction(action, info) {
|
|
31
|
+
let envs = {
|
|
32
|
+
...this.parameters.options?.env,
|
|
33
|
+
...info
|
|
34
|
+
};
|
|
35
|
+
this.log("INFO", "Job", action.getUuid(), "started with", Object.keys(envs)
|
|
36
|
+
.map(k => `${k}=${envs[k]}`)
|
|
37
|
+
.join(" "), this.parameters.command, this.parameters.args ? this.parameters.args.map(a => `'${a}'`).join(" ") : "");
|
|
38
|
+
const child = this.spawn(this.parameters.command, this.parameters.args || [], {
|
|
39
|
+
...this.parameters.options,
|
|
40
|
+
env: envs,
|
|
41
|
+
detached: true
|
|
72
42
|
});
|
|
43
|
+
// AutoStatus based on process info
|
|
44
|
+
if (this.parameters.autoStatus && child) {
|
|
45
|
+
child.stdout?.on("data", data => {
|
|
46
|
+
action.getStore().upsertItemToCollection(action.getUuid(), "logs", data);
|
|
47
|
+
});
|
|
48
|
+
child.stderr?.on("data", data => {
|
|
49
|
+
action.getStore().upsertItemToCollection(action.getUuid(), "logs", data);
|
|
50
|
+
});
|
|
51
|
+
// As this is local just and mostly used for batch auto status it
|
|
52
|
+
await action.getStore().patch({ uuid: action.getUuid(), status: "RUNNING" });
|
|
53
|
+
child.on("exit", async (code) => {
|
|
54
|
+
if (code !== 0) {
|
|
55
|
+
this.log("INFO", "Job", action.getUuid(), "errored with", code);
|
|
56
|
+
await action.getStore().patch({ uuid: action.getUuid(), status: "ERROR" });
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.log("INFO", "Job", action.getUuid(), "successful");
|
|
60
|
+
await action.getStore().patch({ uuid: action.getUuid(), status: "SUCCESS" });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
agent: Runner.getAgentInfo(),
|
|
66
|
+
pid: child?.pid || -1
|
|
67
|
+
};
|
|
73
68
|
}
|
|
74
69
|
}
|
|
75
|
-
exports.default = LocalRunner;
|
|
76
70
|
//# sourceMappingURL=localrunner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localrunner.js","sourceRoot":"","sources":["../../src/services/localrunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localrunner.js","sourceRoot":"","sources":["../../src/services/localrunner.ts"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IAAI,CAAC,CAAC;oBAChE,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;iBAC5E;qBAAM;oBACL,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;oBACxD,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;iBAC9E;YACH,CAAC,CAAC,CAAC;SACJ;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE;YAC5B,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;SACtB,CAAC;IACJ,CAAC;CACF"}
|
package/lib/services/runner.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AsyncAction } from "../models";
|
|
3
|
-
import { JobInfo } from "./asyncjobservice";
|
|
1
|
+
import { Service, ServiceParameters } from "@webda/core";
|
|
2
|
+
import { AsyncAction } from "../models.js";
|
|
3
|
+
import { JobInfo } from "./asyncjobservice.js";
|
|
4
4
|
export declare class RunnerParameters extends ServiceParameters {
|
|
5
5
|
/**
|
|
6
6
|
* Actions managed by the runner
|
package/lib/services/runner.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@webda/core");
|
|
5
|
-
const os = require("os");
|
|
6
|
-
class RunnerParameters extends core_1.ServiceParameters {
|
|
1
|
+
import { Service, ServiceParameters } from "@webda/core";
|
|
2
|
+
import * as os from "os";
|
|
3
|
+
export class RunnerParameters extends ServiceParameters {
|
|
7
4
|
constructor(params) {
|
|
8
|
-
var _a;
|
|
9
5
|
super(params);
|
|
10
|
-
|
|
6
|
+
this.actions ?? (this.actions = []);
|
|
11
7
|
}
|
|
12
8
|
}
|
|
13
|
-
exports.RunnerParameters = RunnerParameters;
|
|
14
9
|
/**
|
|
15
10
|
* Runner take and launch an action
|
|
16
11
|
*/
|
|
17
|
-
class Runner extends
|
|
12
|
+
export class Runner extends Service {
|
|
18
13
|
/**
|
|
19
14
|
* @inheritdoc
|
|
20
15
|
*/
|
|
@@ -27,7 +22,7 @@ class Runner extends core_1.Service {
|
|
|
27
22
|
* @returns
|
|
28
23
|
*/
|
|
29
24
|
handleType(type) {
|
|
30
|
-
return this.parameters.actions
|
|
25
|
+
return this.parameters.actions?.includes(type) ?? false;
|
|
31
26
|
}
|
|
32
27
|
/**
|
|
33
28
|
* Return agent information
|
|
@@ -43,5 +38,4 @@ class Runner extends core_1.Service {
|
|
|
43
38
|
};
|
|
44
39
|
}
|
|
45
40
|
}
|
|
46
|
-
exports.Runner = Runner;
|
|
47
41
|
//# sourceMappingURL=runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/services/runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/services/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAIzB,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IAOrD,YAAY,MAAW;QACrB,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,KAAZ,IAAI,CAAC,OAAO,GAAK,EAAE,EAAC;IACtB,CAAC;CACF;AAoBD;;GAEG;AACH,MAAM,OAAgB,MAAsD,SAAQ,OAAU;IAC5F;;OAEG;IACH,cAAc,CAAC,MAAW;QACxB,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACD;;;;OAIG;IACH,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,YAAY;QACjB,OAAO;YACL,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE;YACvB,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE;YACvB,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE;YACrB,MAAM,EAAE,EAAE,CAAC,QAAQ,EAAE;YACrB,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;SAChB,CAAC;IACJ,CAAC;CAMF"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webda/async",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Async System",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "tsc",
|
|
7
|
+
"build": "tsc-esm",
|
|
8
|
+
"build:module": "webda build",
|
|
8
9
|
"pretest": "npm run build",
|
|
9
|
-
"test": "
|
|
10
|
+
"test": "c8 mocha --recursive --exit --timeout=100000 -r ../../node_modules/ts-node/register src/**/*.spec.ts",
|
|
10
11
|
"run": "node core"
|
|
11
12
|
},
|
|
12
13
|
"keywords": [
|
|
@@ -18,22 +19,19 @@
|
|
|
18
19
|
"package.json"
|
|
19
20
|
],
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"@webda/core": "^2.0.0-beta.3",
|
|
22
|
+
"@webda/core": "^2.1.0",
|
|
23
23
|
"axios": "^0.27.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
26
|
+
"@types/node": "14.6.0",
|
|
27
|
+
"@webda/tsc-esm": "^1.0.1",
|
|
28
28
|
"mocha": "^10.0.0",
|
|
29
|
-
"nyc": "^15.1.0",
|
|
30
29
|
"sinon": "^14.0.0",
|
|
31
30
|
"source-map-support": "^0.5.19",
|
|
32
31
|
"ts-node": "^10.2.0",
|
|
33
32
|
"typescript": "~4.7.2"
|
|
34
33
|
},
|
|
35
|
-
"
|
|
36
|
-
"extends": "@istanbuljs/nyc-config-typescript",
|
|
34
|
+
"c8": {
|
|
37
35
|
"report-dir": "./reports",
|
|
38
36
|
"reporter": [
|
|
39
37
|
"html",
|
|
@@ -59,5 +57,9 @@
|
|
|
59
57
|
"webda": {
|
|
60
58
|
"namespace": "Webda"
|
|
61
59
|
},
|
|
62
|
-
"
|
|
60
|
+
"type": "module",
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=14.6.0"
|
|
63
|
+
},
|
|
64
|
+
"gitHead": "d9e2440a4001c1405132260d221c7ad74fe06bc9"
|
|
63
65
|
}
|
package/webda.module.json
CHANGED
|
@@ -3,8 +3,313 @@
|
|
|
3
3
|
"webda/asyncjobservice": "lib/services/asyncjobservice:default",
|
|
4
4
|
"webda/localrunner": "lib/services/localrunner:default"
|
|
5
5
|
},
|
|
6
|
+
"beans": {},
|
|
6
7
|
"models": {
|
|
7
8
|
"webda/asyncaction": "lib/models:default"
|
|
8
9
|
},
|
|
9
|
-
"deployers": {}
|
|
10
|
-
|
|
10
|
+
"deployers": {},
|
|
11
|
+
"schemas": {
|
|
12
|
+
"webda/asyncaction": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"_creationDate": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"format": "date-time",
|
|
18
|
+
"description": "Creation date",
|
|
19
|
+
"readOnly": true
|
|
20
|
+
},
|
|
21
|
+
"_lastUpdate": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"format": "date-time",
|
|
24
|
+
"description": "Last update date",
|
|
25
|
+
"readOnly": true
|
|
26
|
+
},
|
|
27
|
+
"uuid": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "Action uuid"
|
|
30
|
+
},
|
|
31
|
+
"status": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"enum": [
|
|
34
|
+
"RUNNING",
|
|
35
|
+
"SUCCESS",
|
|
36
|
+
"ERROR",
|
|
37
|
+
"QUEUED",
|
|
38
|
+
"STARTING",
|
|
39
|
+
"TIMEOUT"
|
|
40
|
+
],
|
|
41
|
+
"description": "Current status"
|
|
42
|
+
},
|
|
43
|
+
"errorMessage": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "If an error occured it should contain the message"
|
|
46
|
+
},
|
|
47
|
+
"job": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"description": "Job information"
|
|
50
|
+
},
|
|
51
|
+
"_lastJobUpdate": {
|
|
52
|
+
"type": "number",
|
|
53
|
+
"description": "Last time the job was updated",
|
|
54
|
+
"readOnly": true
|
|
55
|
+
},
|
|
56
|
+
"results": {
|
|
57
|
+
"description": "Results from the job"
|
|
58
|
+
},
|
|
59
|
+
"statusDetails": {
|
|
60
|
+
"description": "Job current status"
|
|
61
|
+
},
|
|
62
|
+
"type": {
|
|
63
|
+
"type": "string"
|
|
64
|
+
},
|
|
65
|
+
"arguments": {
|
|
66
|
+
"type": "array",
|
|
67
|
+
"items": {}
|
|
68
|
+
},
|
|
69
|
+
"logs": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"items": {
|
|
72
|
+
"type": "string"
|
|
73
|
+
},
|
|
74
|
+
"description": "Current logs"
|
|
75
|
+
},
|
|
76
|
+
"action": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "Expected action for the job\n\nIt should be a verb"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"required": [
|
|
82
|
+
"uuid",
|
|
83
|
+
"status",
|
|
84
|
+
"job",
|
|
85
|
+
"results",
|
|
86
|
+
"statusDetails",
|
|
87
|
+
"type",
|
|
88
|
+
"logs"
|
|
89
|
+
],
|
|
90
|
+
"description": "Define here a model that can be used along with Store service",
|
|
91
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
92
|
+
"title": "AsyncAction"
|
|
93
|
+
},
|
|
94
|
+
"webda/asyncjobservice": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"properties": {
|
|
97
|
+
"type": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"description": "Type of the service"
|
|
100
|
+
},
|
|
101
|
+
"url": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"description": "URL to expose job status report hook",
|
|
104
|
+
"default": "/async/jobs"
|
|
105
|
+
},
|
|
106
|
+
"store": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"description": "Store name to use for async actions",
|
|
109
|
+
"default": "AsyncActions"
|
|
110
|
+
},
|
|
111
|
+
"binaryStore": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"description": "If we want to expose a way to upload/download binary for the job\n\nIt will expose a /download and /upload additional url"
|
|
114
|
+
},
|
|
115
|
+
"localLaunch": {
|
|
116
|
+
"type": "boolean",
|
|
117
|
+
"description": "If set runner will be called without queue",
|
|
118
|
+
"default": false
|
|
119
|
+
},
|
|
120
|
+
"queue": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"description": "Queue to post execution to",
|
|
123
|
+
"default": "AsyncActionsQueue"
|
|
124
|
+
},
|
|
125
|
+
"fallbackOnFirst": {
|
|
126
|
+
"type": "boolean",
|
|
127
|
+
"description": "Fallback on first runner if none match",
|
|
128
|
+
"default": false
|
|
129
|
+
},
|
|
130
|
+
"runners": {
|
|
131
|
+
"type": "array",
|
|
132
|
+
"items": {
|
|
133
|
+
"type": "string"
|
|
134
|
+
},
|
|
135
|
+
"description": "Runners to use"
|
|
136
|
+
},
|
|
137
|
+
"concurrencyLimit": {
|
|
138
|
+
"type": "number",
|
|
139
|
+
"description": "Limit the maximum number of jobs running in //"
|
|
140
|
+
},
|
|
141
|
+
"openapi": {
|
|
142
|
+
"type": "object",
|
|
143
|
+
"additionalProperties": true
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"required": [
|
|
147
|
+
"fallbackOnFirst",
|
|
148
|
+
"queue",
|
|
149
|
+
"runners",
|
|
150
|
+
"store",
|
|
151
|
+
"type",
|
|
152
|
+
"url"
|
|
153
|
+
],
|
|
154
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
155
|
+
"title": "AsyncJobService"
|
|
156
|
+
},
|
|
157
|
+
"webda/localrunner": {
|
|
158
|
+
"type": "object",
|
|
159
|
+
"properties": {
|
|
160
|
+
"type": {
|
|
161
|
+
"type": "string",
|
|
162
|
+
"description": "Type of the service"
|
|
163
|
+
},
|
|
164
|
+
"url": {
|
|
165
|
+
"type": "string",
|
|
166
|
+
"description": "URL on which to serve the content"
|
|
167
|
+
},
|
|
168
|
+
"actions": {
|
|
169
|
+
"type": "array",
|
|
170
|
+
"items": {
|
|
171
|
+
"type": "string"
|
|
172
|
+
},
|
|
173
|
+
"description": "Actions managed by the runner",
|
|
174
|
+
"default": []
|
|
175
|
+
},
|
|
176
|
+
"command": {
|
|
177
|
+
"type": "string",
|
|
178
|
+
"description": "Command to launch"
|
|
179
|
+
},
|
|
180
|
+
"args": {
|
|
181
|
+
"type": "array",
|
|
182
|
+
"items": {
|
|
183
|
+
"type": "string"
|
|
184
|
+
},
|
|
185
|
+
"description": "Args"
|
|
186
|
+
},
|
|
187
|
+
"options": {
|
|
188
|
+
"type": "object",
|
|
189
|
+
"properties": {
|
|
190
|
+
"serialization": {
|
|
191
|
+
"$ref": "#/definitions/SerializationType",
|
|
192
|
+
"description": "Specify the kind of serialization used for sending messages between processes.",
|
|
193
|
+
"default": "json"
|
|
194
|
+
},
|
|
195
|
+
"uid": {
|
|
196
|
+
"type": "number"
|
|
197
|
+
},
|
|
198
|
+
"gid": {
|
|
199
|
+
"type": "number"
|
|
200
|
+
},
|
|
201
|
+
"cwd": {
|
|
202
|
+
"type": "string"
|
|
203
|
+
},
|
|
204
|
+
"env": {
|
|
205
|
+
"type": "object",
|
|
206
|
+
"properties": {}
|
|
207
|
+
},
|
|
208
|
+
"windowsHide": {
|
|
209
|
+
"type": "boolean",
|
|
210
|
+
"default": true
|
|
211
|
+
},
|
|
212
|
+
"timeout": {
|
|
213
|
+
"type": "number",
|
|
214
|
+
"default": 0
|
|
215
|
+
},
|
|
216
|
+
"argv0": {
|
|
217
|
+
"type": "string"
|
|
218
|
+
},
|
|
219
|
+
"stdio": {
|
|
220
|
+
"$ref": "#/definitions/StdioOptions"
|
|
221
|
+
},
|
|
222
|
+
"shell": {
|
|
223
|
+
"type": [
|
|
224
|
+
"boolean",
|
|
225
|
+
"string"
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
"windowsVerbatimArguments": {
|
|
229
|
+
"type": "boolean"
|
|
230
|
+
},
|
|
231
|
+
"detached": {
|
|
232
|
+
"type": "boolean"
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"description": "Options\n\nBased on https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options"
|
|
236
|
+
},
|
|
237
|
+
"autoStatus": {
|
|
238
|
+
"type": "boolean",
|
|
239
|
+
"description": "Use the observability of ChildProcess to update status accordingly"
|
|
240
|
+
},
|
|
241
|
+
"openapi": {
|
|
242
|
+
"type": "object",
|
|
243
|
+
"additionalProperties": true
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
"required": [
|
|
247
|
+
"command",
|
|
248
|
+
"type"
|
|
249
|
+
],
|
|
250
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
251
|
+
"definitions": {
|
|
252
|
+
"SerializationType": {
|
|
253
|
+
"type": "string",
|
|
254
|
+
"enum": [
|
|
255
|
+
"json",
|
|
256
|
+
"advanced"
|
|
257
|
+
]
|
|
258
|
+
},
|
|
259
|
+
"StdioOptions": {
|
|
260
|
+
"anyOf": [
|
|
261
|
+
{
|
|
262
|
+
"type": "string",
|
|
263
|
+
"const": "pipe"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"type": "string",
|
|
267
|
+
"const": "ignore"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"type": "string",
|
|
271
|
+
"const": "inherit"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"type": "array",
|
|
275
|
+
"items": {
|
|
276
|
+
"anyOf": [
|
|
277
|
+
{
|
|
278
|
+
"type": "string",
|
|
279
|
+
"const": "pipe"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"type": "string",
|
|
283
|
+
"const": "ipc"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"type": "string",
|
|
287
|
+
"const": "ignore"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"type": "string",
|
|
291
|
+
"const": "inherit"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"type": "object",
|
|
295
|
+
"properties": {}
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"type": "number"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
"type": "null"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"not": {}
|
|
305
|
+
}
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
"title": "LocalRunner"
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|