Cleaned up some comments

This commit is contained in:
iotux 2025-12-15 15:26:09 +01:00
parent 9befa8d4b6
commit fe50adb061

View File

@ -28,17 +28,14 @@ class LocalServiceMonitorType extends MonitorType {
execFile("systemctl", [ "is-active", monitor.local_service_name ], (error, stdout, stderr) => {
// systemctl is-active exits with 0 if the service is active,
// and a non-zero code if it is inactive, failed, or not found.
// 1. Capture the raw output (prioritize stderr for errors)
// stderr often contains useful info like "service not found"
let output = (stderr || stdout || "").toString().trim();
// 2. Truncate if too long to ~200 chars
if (output.length > 200) {
output = output.substring(0, 200) + "...";
}
if (error) {
// stderr often contains useful info like "service not found"
// Use the truncated output, or a default fallback if empty
heartbeat.msg = stderr || stdout || `Service '${monitor.local_service_name}' is not running.`;
reject(new Error(heartbeat.msg));
return;