1---2name: server-management3description: Server management principles and decision-making. Process management, monitoring strategy, and scaling decisions. Teaches thinking, not commands.4license: MIT5---67# Server Management89> Server management principles for production operations.10> **Learn to THINK, not memorize commands.**1112---1314## 1. Process Management Principles1516### Tool Selection1718| Scenario | Tool |19|----------|------|20| **Node.js app** | PM2 (clustering, reload) |21| **Any app** | systemd (Linux native) |22| **Containers** | Docker/Podman |23| **Orchestration** | Kubernetes, Docker Swarm |2425### Process Management Goals2627| Goal | What It Means |28|------|---------------|29| **Restart on crash** | Auto-recovery |30| **Zero-downtime reload** | No service interruption |31| **Clustering** | Use all CPU cores |32| **Persistence** | Survive server reboot |3334---3536## 2. Monitoring Principles3738### What to Monitor3940| Category | Key Metrics |41|----------|-------------|42| **Availability** | Uptime, health checks |43| **Performance** | Response time, throughput |44| **Errors** | Error rate, types |45| **Resources** | CPU, memory, disk |4647### Alert Severity Strategy4849| Level | Response |50|-------|----------|51| **Critical** | Immediate action |52| **Warning** | Investigate soon |53| **Info** | Review daily |5455### Monitoring Tool Selection5657| Need | Options |58|------|---------|59| Simple/Free | PM2 metrics, htop |60| Full observability | Grafana, Datadog |61| Error tracking | Sentry |62| Uptime | UptimeRobot, Pingdom |6364---6566## 3. Log Management Principles6768### Log Strategy6970| Log Type | Purpose |71|----------|---------|72| **Application logs** | Debug, audit |73| **Access logs** | Traffic analysis |74| **Error logs** | Issue detection |7576### Log Principles77781. **Rotate logs** to prevent disk fill792. **Structured logging** (JSON) for parsing803. **Appropriate levels** (error/warn/info/debug)814. **No sensitive data** in logs8283---8485## 4. Scaling Decisions8687### When to Scale8889| Symptom | Solution |90|---------|----------|91| High CPU | Add instances (horizontal) |92| High memory | Increase RAM or fix leak |93| Slow response | Profile first, then scale |94| Traffic spikes | Auto-scaling |9596### Scaling Strategy9798| Type | When to Use |99|------|-------------|100| **Vertical** | Quick fix, single instance |101| **Horizontal** | Sustainable, distributed |102| **Auto** | Variable traffic |103104---105106## 5. Health Check Principles107108### What Constitutes Healthy109110| Check | Meaning |111|-------|---------|112| **HTTP 200** | Service responding |113| **Database connected** | Data accessible |114| **Dependencies OK** | External services reachable |115| **Resources OK** | CPU/memory not exhausted |116117### Health Check Implementation118119- Simple: Just return 200120- Deep: Check all dependencies121- Choose based on load balancer needs122123---124125## 6. Security Principles126127| Area | Principle |128|------|-----------|129| **Access** | SSH keys only, no passwords |130| **Firewall** | Only needed ports open |131| **Updates** | Regular security patches |132| **Secrets** | Environment vars, not files |133| **Audit** | Log access and changes |134135---136137## 7. Troubleshooting Priority138139When something's wrong:1401411. **Check if running** (process status)1422. **Check logs** (error messages)1433. **Check resources** (disk, memory, CPU)1444. **Check network** (ports, DNS)1455. **Check dependencies** (database, APIs)146147---148149## 8. Anti-Patterns150151| ❌ Don't | ✅ Do |152|----------|-------|153| Run as root | Use non-root user |154| Ignore logs | Set up log rotation |155| Skip monitoring | Monitor from day one |156| Manual restarts | Auto-restart config |157| No backups | Regular backup schedule |158159---160161> **Remember:** A well-managed server is boring. That's the goal.162163## When to Use164This skill is applicable to execute the workflow or actions described in the overview.165166## Limitations167- Use this skill only when the task clearly matches the scope described above.168- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.169- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.