$npx -y skills add One-Man-Company/Skills-ContextManager --skill server-managementServer management principles and decision-making. Process management, monitoring strategy, and scaling decisions. Teaches thinking, not commands.
| 1 | # Server Management |
| 2 | |
| 3 | > Server management principles for production operations. |
| 4 | > **Learn to THINK, not memorize commands.** |
| 5 | |
| 6 | --- |
| 7 | |
| 8 | ## 1. Process Management Principles |
| 9 | |
| 10 | ### Tool Selection |
| 11 | |
| 12 | | Scenario | Tool | |
| 13 | |----------|------| |
| 14 | | **Node.js app** | PM2 (clustering, reload) | |
| 15 | | **Any app** | systemd (Linux native) | |
| 16 | | **Containers** | Docker/Podman | |
| 17 | | **Orchestration** | Kubernetes, Docker Swarm | |
| 18 | |
| 19 | ### Process Management Goals |
| 20 | |
| 21 | | Goal | What It Means | |
| 22 | |------|---------------| |
| 23 | | **Restart on crash** | Auto-recovery | |
| 24 | | **Zero-downtime reload** | No service interruption | |
| 25 | | **Clustering** | Use all CPU cores | |
| 26 | | **Persistence** | Survive server reboot | |
| 27 | |
| 28 | --- |
| 29 | |
| 30 | ## 2. Monitoring Principles |
| 31 | |
| 32 | ### What to Monitor |
| 33 | |
| 34 | | Category | Key Metrics | |
| 35 | |----------|-------------| |
| 36 | | **Availability** | Uptime, health checks | |
| 37 | | **Performance** | Response time, throughput | |
| 38 | | **Errors** | Error rate, types | |
| 39 | | **Resources** | CPU, memory, disk | |
| 40 | |
| 41 | ### Alert Severity Strategy |
| 42 | |
| 43 | | Level | Response | |
| 44 | |-------|----------| |
| 45 | | **Critical** | Immediate action | |
| 46 | | **Warning** | Investigate soon | |
| 47 | | **Info** | Review daily | |
| 48 | |
| 49 | ### Monitoring Tool Selection |
| 50 | |
| 51 | | Need | Options | |
| 52 | |------|---------| |
| 53 | | Simple/Free | PM2 metrics, htop | |
| 54 | | Full observability | Grafana, Datadog | |
| 55 | | Error tracking | Sentry | |
| 56 | | Uptime | UptimeRobot, Pingdom | |
| 57 | |
| 58 | --- |
| 59 | |
| 60 | ## 3. Log Management Principles |
| 61 | |
| 62 | ### Log Strategy |
| 63 | |
| 64 | | Log Type | Purpose | |
| 65 | |----------|---------| |
| 66 | | **Application logs** | Debug, audit | |
| 67 | | **Access logs** | Traffic analysis | |
| 68 | | **Error logs** | Issue detection | |
| 69 | |
| 70 | ### Log Principles |
| 71 | |
| 72 | 1. **Rotate logs** to prevent disk fill |
| 73 | 2. **Structured logging** (JSON) for parsing |
| 74 | 3. **Appropriate levels** (error/warn/info/debug) |
| 75 | 4. **No sensitive data** in logs |
| 76 | |
| 77 | --- |
| 78 | |
| 79 | ## 4. Scaling Decisions |
| 80 | |
| 81 | ### When to Scale |
| 82 | |
| 83 | | Symptom | Solution | |
| 84 | |---------|----------| |
| 85 | | High CPU | Add instances (horizontal) | |
| 86 | | High memory | Increase RAM or fix leak | |
| 87 | | Slow response | Profile first, then scale | |
| 88 | | Traffic spikes | Auto-scaling | |
| 89 | |
| 90 | ### Scaling Strategy |
| 91 | |
| 92 | | Type | When to Use | |
| 93 | |------|-------------| |
| 94 | | **Vertical** | Quick fix, single instance | |
| 95 | | **Horizontal** | Sustainable, distributed | |
| 96 | | **Auto** | Variable traffic | |
| 97 | |
| 98 | --- |
| 99 | |
| 100 | ## 5. Health Check Principles |
| 101 | |
| 102 | ### What Constitutes Healthy |
| 103 | |
| 104 | | Check | Meaning | |
| 105 | |-------|---------| |
| 106 | | **HTTP 200** | Service responding | |
| 107 | | **Database connected** | Data accessible | |
| 108 | | **Dependencies OK** | External services reachable | |
| 109 | | **Resources OK** | CPU/memory not exhausted | |
| 110 | |
| 111 | ### Health Check Implementation |
| 112 | |
| 113 | - Simple: Just return 200 |
| 114 | - Deep: Check all dependencies |
| 115 | - Choose based on load balancer needs |
| 116 | |
| 117 | --- |
| 118 | |
| 119 | ## 6. Security Principles |
| 120 | |
| 121 | | Area | Principle | |
| 122 | |------|-----------| |
| 123 | | **Access** | SSH keys only, no passwords | |
| 124 | | **Firewall** | Only needed ports open | |
| 125 | | **Updates** | Regular security patches | |
| 126 | | **Secrets** | Environment vars, not files | |
| 127 | | **Audit** | Log access and changes | |
| 128 | |
| 129 | --- |
| 130 | |
| 131 | ## 7. Troubleshooting Priority |
| 132 | |
| 133 | When something's wrong: |
| 134 | |
| 135 | 1. **Check if running** (process status) |
| 136 | 2. **Check logs** (error messages) |
| 137 | 3. **Check resources** (disk, memory, CPU) |
| 138 | 4. **Check network** (ports, DNS) |
| 139 | 5. **Check dependencies** (database, APIs) |
| 140 | |
| 141 | --- |
| 142 | |
| 143 | ## 8. Anti-Patterns |
| 144 | |
| 145 | | ❌ Don't | ✅ Do | |
| 146 | |----------|-------| |
| 147 | | Run as root | Use non-root user | |
| 148 | | Ignore logs | Set up log rotation | |
| 149 | | Skip monitoring | Monitor from day one | |
| 150 | | Manual restarts | Auto-restart config | |
| 151 | | No backups | Regular backup schedule | |
| 152 | |
| 153 | --- |
| 154 | |
| 155 | > **Remember:** A well-managed server is boring. That's the goal. |