mirror of
https://github.com/koichixD/uptime-kuma.git
synced 2026-09-04 17:23:21 +00:00
Cleaned up some comments
This commit is contained in:
@@ -28,17 +28,14 @@ class LocalServiceMonitorType extends MonitorType {
|
|||||||
execFile("systemctl", [ "is-active", monitor.local_service_name ], (error, stdout, stderr) => {
|
execFile("systemctl", [ "is-active", monitor.local_service_name ], (error, stdout, stderr) => {
|
||||||
// systemctl is-active exits with 0 if the service is active,
|
// systemctl is-active exits with 0 if the service is active,
|
||||||
// and a non-zero code if it is inactive, failed, or not found.
|
// 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();
|
let output = (stderr || stdout || "").toString().trim();
|
||||||
|
|
||||||
// 2. Truncate if too long to ~200 chars
|
|
||||||
if (output.length > 200) {
|
if (output.length > 200) {
|
||||||
output = output.substring(0, 200) + "...";
|
output = output.substring(0, 200) + "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
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.`;
|
heartbeat.msg = stderr || stdout || `Service '${monitor.local_service_name}' is not running.`;
|
||||||
reject(new Error(heartbeat.msg));
|
reject(new Error(heartbeat.msg));
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user