1---2name: server-management3description: "Linux server process management, monitoring, logs and scaling. Use when operating or troubleshooting servers."4allowed-tools: Read Write Edit Glob Grep Bash5metadata:6 source: https://skillmd.com/skills/jeffersonvalente/server-management7---89# Server Management1011> Server management principles for production operations.12> **Learn to think, not memorize commands.**1314---1516## 1. Process Management Principles1718### Tool Selection1920| Scenario | Tool |21|----------|------|22| **Node.js app** | PM2 (clustering, reload) |23| **Any app** | systemd (Linux native) |24| **Containers** | Docker/Podman |25| **Orchestration** | Kubernetes, Docker Swarm |2627### Process Management Goals2829| Goal | What It Means |30|------|---------------|31| **Restart on crash** | Auto-recovery |32| **Zero-downtime reload** | No service interruption |33| **Clustering** | Use all CPU cores |34| **Persistence** | Survive server reboot |3536---3738## 2. Monitoring Principles3940### What to Monitor4142| Category | Key Metrics |43|----------|-------------|44| **Availability** | Uptime, health checks |45| **Performance** | Response time, throughput |46| **Errors** | Error rate, types |47| **Resources** | CPU, memory, disk |4849### Alert Severity Strategy5051| Level | Response |52|-------|----------|53| **Critical** | Immediate action |54| **Warning** | Investigate soon |55| **Info** | Review daily |5657### Monitoring Tool Selection5859| Need | Options |60|------|---------|61| Simple/Free | PM2 metrics, htop |62| Full observability | Grafana, Datadog |63| Error tracking | Sentry |64| Uptime | UptimeRobot, Pingdom |6566---6768## 3. Log Management Principles6970### Log Strategy7172| Log Type | Purpose |73|----------|---------|74| **Application logs** | Debug, audit |75| **Access logs** | Traffic analysis |76| **Error logs** | Issue detection |7778### Log Principles79801. **Rotate logs** to prevent disk fill812. **Structured logging** (JSON) for parsing823. **Appropriate levels** (error/warn/info/debug)834. **No sensitive data** in logs8485---8687## 4. Scaling Decisions8889### When to Scale9091| Symptom | Solution |92|---------|----------|93| High CPU | Add instances (horizontal) |94| High memory | Increase RAM or fix leak |95| Slow response | Profile first, then scale |96| Traffic spikes | Auto-scaling |9798### Scaling Strategy99100| Type | When to Use |101|------|-------------|102| **Vertical** | Quick fix, single instance |103| **Horizontal** | Sustainable, distributed |104| **Auto** | Variable traffic |105106---107108## 5. Health Check Principles109110### What Constitutes Healthy111112| Check | Meaning |113|-------|---------|114| **HTTP 200** | Service responding |115| **Database connected** | Data accessible |116| **Dependencies OK** | External services reachable |117| **Resources OK** | CPU/memory not exhausted |118119### Health Check Implementation120121- Simple: Just return 200122- Deep: Check all dependencies123- Choose based on load balancer needs124125---126127## 6. Security Principles128129| Area | Principle |130|------|-----------|131| **Access** | SSH keys only, no passwords |132| **Firewall** | Only needed ports open |133| **Updates** | Regular security patches |134| **Secrets** | Environment vars, not files |135| **Audit** | Log access and changes |136137---138139## 7. Troubleshooting Priority140141When something's wrong:1421431. **Check if running** (process status)1442. **Check logs** (error messages)1453. **Check resources** (disk, memory, CPU)1464. **Check network** (ports, DNS)1475. **Check dependencies** (database, APIs)148149---150151## 8. Anti-Patterns152153| ❌ Don't | ✅ Do |154|----------|-------|155| Run as root | Use non-root user |156| Ignore logs | Set up log rotation |157| Skip monitoring | Monitor from day one |158| Manual restarts | Auto-restart config |159| No backups | Regular backup schedule |160161---162163> **Remember:** A well-managed server is boring. That's the goal.