k6lab-agent 1.0.1 → 1.0.2
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/package.json +1 -1
- package/src/commands/start.js +18 -1
package/package.json
CHANGED
package/src/commands/start.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
2
3
|
import { checkK6Installed } from "../services/k6Checker.js";
|
|
3
4
|
import {
|
|
4
5
|
sendHeartbeat,
|
|
@@ -86,8 +87,11 @@ export async function start() {
|
|
|
86
87
|
}
|
|
87
88
|
}, 2000);
|
|
88
89
|
|
|
90
|
+
let scriptPath = null;
|
|
89
91
|
try {
|
|
90
|
-
const
|
|
92
|
+
const scriptDetails = await createK6Script(job);
|
|
93
|
+
scriptPath = scriptDetails.scriptPath;
|
|
94
|
+
const { summaryPath, logsPath } = scriptDetails;
|
|
91
95
|
|
|
92
96
|
const runResult = await runK6(scriptPath, job, logsPath);
|
|
93
97
|
|
|
@@ -133,6 +137,12 @@ export async function start() {
|
|
|
133
137
|
console.log("");
|
|
134
138
|
console.log("Waiting for jobs...");
|
|
135
139
|
console.log("");
|
|
140
|
+
|
|
141
|
+
if (scriptPath) {
|
|
142
|
+
try {
|
|
143
|
+
await fs.remove(path.dirname(scriptPath));
|
|
144
|
+
} catch (cleanErr) {}
|
|
145
|
+
}
|
|
136
146
|
continue;
|
|
137
147
|
}
|
|
138
148
|
} catch (statusErr) {
|
|
@@ -154,6 +164,13 @@ export async function start() {
|
|
|
154
164
|
|
|
155
165
|
console.log("Waiting for jobs...");
|
|
156
166
|
console.log("");
|
|
167
|
+
} finally {
|
|
168
|
+
// 🧹 Clean up local job folder on success or error
|
|
169
|
+
if (scriptPath) {
|
|
170
|
+
try {
|
|
171
|
+
await fs.remove(path.dirname(scriptPath));
|
|
172
|
+
} catch (cleanErr) {}
|
|
173
|
+
}
|
|
157
174
|
}
|
|
158
175
|
} catch (err) {
|
|
159
176
|
console.error("Agent connection error:", err.message);
|