Linux & service basics: logs, systemd/PM2, permissions, Nginx reverse proxy, DNS checks
PURPOSE
Diagnoses common Linux service issues using logs, systemd/PM2, file permissions, Nginx reverse proxy checks, and DNS sanity checks.
WHEN TO USE
- TRIGGERS:
- Show me why this service is failing using logs, then give the exact fix commands.
- Restart this app cleanly and confirm it is listening on the right port.
- Fix the permissions on this folder so the service can read and write safely.
- Set up Nginx reverse proxy for this port and verify DNS and TLS are sane.
- Create a systemd service for this script and make it survive reboots.
- DO NOT USE WHEN…
- You need kernel debugging or deep performance profiling.
- You want to exploit systems or bypass access controls.
INPUTS
- REQUIRED:
- Service type: systemd unit name or PM2 process name.
- Observed symptom: error message, status output, or logs (pasted by user).
- OPTIONAL:
- Nginx config snippet, domain name, expected upstream port.
- Filesystem paths used by the service.
- EXAMPLES:
systemctl status myapp output + journalctl excerpt
- Nginx server block + domain + upstream port
OUTPUTS
- Default: triage report (likely cause, evidence from logs, minimal fix plan).
- If explicitly requested and safe: exact shell commands to apply the fix.
Success = service runs, listens on expected port, and reverse proxy/DNS path is correct.
WORKFLOW
- Confirm scope and safety:
- identify service name and whether changes are permitted.
- Gather evidence:
- status output + recent logs (see
references/triage-commands.md).
- Classify failure:
- config error, dependency missing, permission denied, port conflict, upstream unreachable, DNS mismatch.
- Propose minimal fix + verification steps.
- Validate network path (if web service):
- app listens → Nginx proxies → DNS resolves → (TLS sanity if applicable).
- Provide restart/reload plan and confirm health checks.
- STOP AND ASK THE USER if:
- logs/status output are missing,
- actions require privileged access not confirmed,
- TLS/cert management is required but setup is unknown.
OUTPUT FORMAT
TRIAGE REPORT
- Symptom:
- Evidence (what you provided):
- Most likely cause:
- Fix plan (minimal steps):
- Exact commands (ONLY if user approved changes):
- Verification:
- Rollback:
SAFETY & EDGE CASES
- Read-only by default: diagnose from provided outputs; do not assume you can run commands.
- Avoid destructive changes; require explicit confirmation for anything risky.
- Prefer
nginx -t before reload and verify ports with ss.
EXAMPLES
Input: “journal shows permission denied on /var/app/uploads.”
Output: path permission analysis + safe chown/chmod plan + verification.
Input: “App works locally but domain returns 502.”
Output: upstream port checks + nginx error log interpretation + proxy_pass fix plan.
1---2name: linux-service-triage3description: Diagnoses common Linux service issues using logs, systemd/PM2, file permissions, Nginx reverse proxy checks, and DNS sanity checks. Use when a server app is failing, unreachable, or misconfigured.4---56# Linux & service basics: logs, systemd/PM2, permissions, Nginx reverse proxy, DNS checks78## PURPOSE9Diagnoses common Linux service issues using logs, systemd/PM2, file permissions, Nginx reverse proxy checks, and DNS sanity checks.1011## WHEN TO USE12- TRIGGERS:13 - Show me why this service is failing using logs, then give the exact fix commands.14 - Restart this app cleanly and confirm it is listening on the right port.15 - Fix the permissions on this folder so the service can read and write safely.16 - Set up Nginx reverse proxy for this port and verify DNS and TLS are sane.17 - Create a systemd service for this script and make it survive reboots.18- DO NOT USE WHEN…19 - You need kernel debugging or deep performance profiling.20 - You want to exploit systems or bypass access controls.2122## INPUTS23- REQUIRED:24 - Service type: systemd unit name or PM2 process name.25 - Observed symptom: error message, status output, or logs (pasted by user).26- OPTIONAL:27 - Nginx config snippet, domain name, expected upstream port.28 - Filesystem paths used by the service.29- EXAMPLES:30 - `systemctl status myapp` output + `journalctl` excerpt31 - Nginx server block + domain + upstream port3233## OUTPUTS34- Default: triage report (likely cause, evidence from logs, minimal fix plan).35- If explicitly requested and safe: exact shell commands to apply the fix.36Success = service runs, listens on expected port, and reverse proxy/DNS path is correct.373839## WORKFLOW401. Confirm scope and safety:41 - identify service name and whether changes are permitted.422. Gather evidence:43 - status output + recent logs (see `references/triage-commands.md`).443. Classify failure:45 - config error, dependency missing, permission denied, port conflict, upstream unreachable, DNS mismatch.464. Propose minimal fix + verification steps.475. Validate network path (if web service):48 - app listens → Nginx proxies → DNS resolves → (TLS sanity if applicable).496. Provide restart/reload plan and confirm health checks.507. STOP AND ASK THE USER if:51 - logs/status output are missing,52 - actions require privileged access not confirmed,53 - TLS/cert management is required but setup is unknown.545556## OUTPUT FORMAT57```text58TRIAGE REPORT59- Symptom:60- Evidence (what you provided):61- Most likely cause:62- Fix plan (minimal steps):63- Exact commands (ONLY if user approved changes):64- Verification:65- Rollback:66```676869## SAFETY & EDGE CASES70- Read-only by default: diagnose from provided outputs; do not assume you can run commands.71- Avoid destructive changes; require explicit confirmation for anything risky.72- Prefer `nginx -t` before reload and verify ports with `ss`.737475## EXAMPLES76- Input: “journal shows permission denied on /var/app/uploads.” 77 Output: path permission analysis + safe chown/chmod plan + verification.7879- Input: “App works locally but domain returns 502.” 80 Output: upstream port checks + nginx error log interpretation + proxy_pass fix plan.81