Skip to content

Commit

Permalink
fix(qseow): Make writing reload script logs to disk more robust
Browse files Browse the repository at this point in the history
Fixes #1296
  • Loading branch information
mountaindude committed Nov 30, 2024
1 parent ebe8c44 commit d42f27d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 35 deletions.
70 changes: 35 additions & 35 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/src/butler.js",
// "runtimeVersion": "20",
"runtimeVersion": "18",
// "runtimeVersion": "23",
"cwd": "${workspaceFolder}/src",
"env": {
"NODE_CONFIG_DIR": "${workspaceFolder}/src/config",
"NODE_ENV": "production"
},
"args": [
"--configfile",
"config/production.yaml",
// "config/production_template.yaml",
// "--new-relic-account-name",
// "'First NR account'",
// "--new-relic-account-id",
// "ACCOUNTID",
// "--new-relic-api-key",
// "APIKEY",
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/src/butler.js",
// "runtimeVersion": "20",
"runtimeVersion": "18",
// "runtimeVersion": "23",
"cwd": "${workspaceFolder}/src",
"env": {
"NODE_CONFIG_DIR": "${workspaceFolder}/src/config",
"NODE_ENV": "production"
},
"args": [
"--configfile",
"config/production.yaml"
// "config/production_template.yaml",
// "--new-relic-account-name",
// "'First NR account'",
// "--new-relic-account-id",
// "ACCOUNTID",
// "--new-relic-api-key",
// "APIKEY",

// "-c",
// "./config/config-gen-api-docs.yaml",
// "--no-qs-connection"
],
"outFiles": ["${workspaceFolder}/**/*.js"]
}
]
// "-c",
// "./config/config-gen-api-docs.yaml",
// "--no-qs-connection"
],
"outFiles": ["${workspaceFolder}/**/*.js"]
}
]
}
14 changes: 14 additions & 0 deletions src/lib/qseow/scriptlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,20 @@ export async function failedTaskStoreLogOnDisk(reloadParams) {
);

globals.logger.info(`[QSEOW] SCRIPTLOG STORE: Writing failed task script log: ${fileName}`);

// Do we have a script log to store?
if (!scriptLog.scriptLogFull) {
globals.logger.error('[QSEOW] SCRIPTLOG STORE: A script log should be available, but it is not. Possibly because the QRS API did not return one.');
return false;
} else if (scriptLog.scriptLogFull.length === 0) {
globals.logger.error('[QSEOW] SCRIPTLOG STORE: A script log is available, but it is empty (zero rows in it).');
return false;
} else if (scriptLog.scriptLogFull.length < 10) {
globals.logger.warn('[QSEOW] SCRIPTLOG STORE: A script log is available, but it is very short (less than 10 rows).');
} else {
globals.logger.verbose(`[QSEOW] SCRIPTLOG STORE: Script log is available and has ${scriptLog.scriptLogFull.length} rows.`);
}

fs.writeFileSync(fileName, scriptLog.scriptLogFull.join('\n'));
return true;
} catch (err) {
Expand Down

0 comments on commit d42f27d

Please sign in to comment.