@kumologica/sdk 3.6.4-beta5 → 3.6.4-beta6
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/cli/commands/run.js +58 -22
- package/package.json +4 -4
package/cli/commands/run.js
CHANGED
|
@@ -54,6 +54,12 @@ exports.builder = (yargs) => {
|
|
|
54
54
|
alias: "t",
|
|
55
55
|
nargs: 1,
|
|
56
56
|
});
|
|
57
|
+
yargs.option(`taskTimeout`, {
|
|
58
|
+
describe: "The timeout in seconds for task execution.",
|
|
59
|
+
type: "number",
|
|
60
|
+
alias: "o",
|
|
61
|
+
nargs: 1,
|
|
62
|
+
});
|
|
57
63
|
yargs.option(`args`, {
|
|
58
64
|
describe: "The list of arguments, either '-a one two three' or '-a one -a two -a three' ",
|
|
59
65
|
type: "array",
|
|
@@ -67,13 +73,15 @@ exports.handler = async ({ project_directory, loglevel, port, taskName, args })
|
|
|
67
73
|
// project_directory can point to a directory or a flow, so lets make sure that first the directory exists
|
|
68
74
|
let absProjectDirectory;
|
|
69
75
|
let exitCode = 1;
|
|
76
|
+
|
|
70
77
|
try {
|
|
71
78
|
absProjectDirectory = fs.realpathSync(projectDirectory);
|
|
72
79
|
} catch (err) {
|
|
73
80
|
logFatal(`Project not found: ${projectDirectory}`);
|
|
74
81
|
process.exit(exitCode);
|
|
75
82
|
}
|
|
76
|
-
|
|
83
|
+
|
|
84
|
+
let server;
|
|
77
85
|
try {
|
|
78
86
|
// Resolve the path to the flow path
|
|
79
87
|
const [projectFlowDirname, projectFlowFullPath] = resolveProjectFlowPath(absProjectDirectory);
|
|
@@ -87,35 +95,63 @@ exports.handler = async ({ project_directory, loglevel, port, taskName, args })
|
|
|
87
95
|
};
|
|
88
96
|
|
|
89
97
|
// Start a server
|
|
90
|
-
|
|
98
|
+
server = new TaskServer(projectFlowFullPath, cliParams);
|
|
91
99
|
|
|
92
100
|
await server.listen();
|
|
93
101
|
|
|
102
|
+
const got = require('got');
|
|
103
|
+
|
|
104
|
+
// Timeout in ms (default 10 minutes); make configurable via env or param if needed
|
|
105
|
+
const TIMEOUT_MS = process.env.TIMEOUT_MS || 1000000; // 10 minutes
|
|
106
|
+
|
|
94
107
|
const tName = taskName || process.env.taskName;
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
const url = `http://127.0.0.1:${port || 1880}/__task__/${tName}`;
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const response = await got(url, {
|
|
112
|
+
method: 'POST',
|
|
113
|
+
headers: {
|
|
114
|
+
// Add any specific headers here if needed (e.g., 'Content-Type': 'application/json')
|
|
115
|
+
},
|
|
116
|
+
json: { args: args }, // Automatically stringifies to JSON and sets Content-Type
|
|
117
|
+
timeout: { request: TIMEOUT_MS } // Full request timeout (headers + body)
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Log success and response details
|
|
121
|
+
logInfo('Request succeeded!');
|
|
122
|
+
logInfo('Status:', response.statusCode);
|
|
123
|
+
logInfo('Response body:', response.body); // Assuming JSON response; parse if needed via response.json
|
|
124
|
+
|
|
125
|
+
exitCode = 0;
|
|
126
|
+
|
|
127
|
+
} catch (error) {
|
|
128
|
+
// Log failure details
|
|
129
|
+
logFatal('Task Error:', error.message);
|
|
130
|
+
|
|
131
|
+
// if (error.response) {
|
|
132
|
+
// logFatal('Status:', error.response.statusCode);
|
|
133
|
+
// logFatal('Response body:', error.response.body);
|
|
134
|
+
// }
|
|
135
|
+
// if (error.code === 'ETIMEDOUT') {
|
|
136
|
+
// logFatal('Timeout exceeded (', TIMEOUT_MS / 1000, 's)');
|
|
137
|
+
// }
|
|
138
|
+
}
|
|
139
|
+
} catch (error) {
|
|
140
|
+
logFatal('Task failed!');
|
|
141
|
+
logFatal('Error:', error.message);
|
|
101
142
|
|
|
102
|
-
|
|
103
|
-
const url = `http://127.0.0.1:${port||1880}/__task__/${tName}`;
|
|
104
|
-
|
|
105
|
-
const response = await fetch(url, req);
|
|
106
|
-
const data = await response.text();
|
|
107
|
-
|
|
108
|
-
logInfo("Status: " + response.status);
|
|
109
|
-
logInfo("Message: " + data);
|
|
143
|
+
}
|
|
110
144
|
|
|
145
|
+
try {
|
|
146
|
+
if (server) {
|
|
111
147
|
await server.stop();
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
} catch (e) {
|
|
117
|
-
logFatal(e.message);
|
|
148
|
+
}
|
|
149
|
+
} catch (error) {
|
|
150
|
+
logError('Error stopping server:', error.message);
|
|
118
151
|
}
|
|
152
|
+
logInfo('HTTP Server stopped.');
|
|
153
|
+
|
|
154
|
+
process.exit(exitCode); // Error exit
|
|
119
155
|
};
|
|
120
156
|
|
|
121
157
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kumologica/sdk",
|
|
3
|
-
"version": "3.6.4-
|
|
3
|
+
"version": "3.6.4-beta6",
|
|
4
4
|
"productName": "Kumologica Designer",
|
|
5
5
|
"copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
|
|
6
6
|
"author": "Kumologica Pty Ltd <contact@kumologica.com>",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"@aws-sdk/credential-providers": "^3.556.0",
|
|
84
84
|
"@aws-sdk/lib-dynamodb": "^3.549.0",
|
|
85
85
|
"@electron/remote": "^2.0.8",
|
|
86
|
-
"@kumologica/builder": "3.6.4-
|
|
87
|
-
"@kumologica/devkit": "3.6.4-
|
|
88
|
-
"@kumologica/runtime": "3.6.4-
|
|
86
|
+
"@kumologica/builder": "3.6.4-beta6",
|
|
87
|
+
"@kumologica/devkit": "3.6.4-beta6",
|
|
88
|
+
"@kumologica/runtime": "3.6.4-beta6",
|
|
89
89
|
"ajv": "8.10.0",
|
|
90
90
|
"archive-type": "^4.0.0",
|
|
91
91
|
"basic-auth": "2.0.1",
|