-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_script_output_content.js
More file actions
33 lines (27 loc) · 1.11 KB
/
verify_script_output_content.js
File metadata and controls
33 lines (27 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env node
/**
* Verify Script Output Content
* Problem: Script runs successfully but output is missing or wrong
* Solution: Validate output content after script execution
* Documentation: https://deadmanping.com/verify-script-output-content
*/
const { execSync } = require('child_process');
const fs = require('fs');
const https = require('https');
const MONITOR_ID = 'YOUR_MONITOR_ID'; // Replace with your actual monitor ID
// Run script
execSync('./process-data.sh');
// Get output file data
const outputFile = '/output/processed-data.json';
let fileExists = fs.existsSync(outputFile);
let hasStatusField = false;
if (fileExists) {
const content = fs.readFileSync(outputFile, 'utf8');
hasStatusField = content.includes('"status": "success"');
}
// Always ping with output data in payload
// In DeadManPing panel: set validation rules:
// - "file_exists" == true
// - "has_status_field" == true
// Panel will automatically detect if output is invalid
https.request(`https://deadmanping.com/api/ping/${MONITOR_ID}?file_exists=${fileExists}&has_status_field=${hasStatusField}`, { method: 'POST' }).end();