diff --git a/src/controllers/status.js b/src/controllers/status.js index 7321ca9..f13e2a3 100644 --- a/src/controllers/status.js +++ b/src/controllers/status.js @@ -73,13 +73,13 @@ export default function () { lastTestOK = lastTestResult.status == 'OK'; lastTest = Date.now(); } - res.status(lastTestOK ? 200 : 500).json(lastTestResult); if (lastTestResult.codes.nginx === 1) { await fixNGINX(lastTestResult); } if (lastTestResult.codes.fpms.some(x => x === 1)) { await fixPHP(lastTestResult); } + res.status(lastTestOK ? 200 : 500).json(lastTestResult); } catch (error) { next(error); } diff --git a/src/executor/pulse.js b/src/executor/pulse.js index ceaa03c..6e5c0c2 100644 --- a/src/executor/pulse.js +++ b/src/executor/pulse.js @@ -1,6 +1,7 @@ import { spawnSudoUtil } from "../util.js"; export async function fixPHP(test) { + const edits = []; for (const [name, logs] of Object.entries(test.logs.fpms)) { const [lastLog] = logs.splice(logs.length - 1); if (lastLog.endsWith("ERROR: FPM initialization failed")) { @@ -8,15 +9,19 @@ export async function fixPHP(test) { let m = element.match(/ALERT: \[pool (\d+)\]/); if (m) { await spawnSudoUtil("CLEAN_DOMAIN", ["mv", m[1], ""]); + edits.push(m[1]); } } } } + test.fixes = test.fixes || {}; + test.fixes.fpm = edits; } export async function fixNGINX(test) { const logs = test.logs.nginx; const [lastLog] = logs.splice(logs.length - 1); + const edits = []; if (lastLog == "nginx: configuration file /etc/nginx/nginx.conf test failed") { for (const element of logs) { let m = element.match(/nginx: \[emerg\] cannot load certificate \"([\w.\/]+)\"/); @@ -28,10 +33,13 @@ export async function fixNGINX(test) { let m2 = f.match(/\/etc\/nginx\/conf.d\/(.+)\.conf/); if (m2) { await spawnSudoUtil("CLEAN_DOMAIN", ["mv", "", m2[1]]); + edits.push(m2[1]); } } } } } + test.fixes = test.fixes || {}; + test.fixes.nginx = edits; }