1---2name: server-management3description: Server management principles and decision-making. Process management, monitoring strategy, and scaling decisions. Teaches thinking, not commands.4---56# Server Management78> Server management principles for production operations.9> **Learn to THINK, not memorize commands.**1011---1213## 1. Process Management Principles1415### Tool Selection1617| Scenario | Tool |18|----------|------|19| **Node.js app** | PM2 (clustering, reload) |20| **Any app** | systemd (Linux native) |21| **Containers** | Docker/Podman |22| **Orchestration** | Kubernetes, Docker Swarm |2324### Process Management Goals2526| Goal | What It Means |27|------|---------------|28| **Restart on crash** | Auto-recovery |29| **Zero-downtime reload** | No service interruption |30| **Clustering** | Use all CPU cores |31| **Persistence** | Survive server reboot |3233---3435## 2. Monitoring Principles3637### What to Monitor3839| Category | Key Metrics |40|----------|-------------|41| **Availability** | Uptime, health checks |42| **Performance** | Response time, throughput |43| **Errors** | Error rate, types |44| **Resources** | CPU, memory, disk |4546### Alert Severity Strategy4748| Level | Response |49|-------|----------|50| **Critical** | Immediate action |51| **Warning** | Investigate soon |52| **Info** | Review daily |5354### Monitoring Tool Selection5556| Need | Options |57|------|---------|58| Simple/Free | PM2 metrics, htop |59| Full observability | Grafana, Datadog |60| Error tracking | Sentry |61| Uptime | UptimeRobot, Pingdom |6263---6465## 3. Log Management Principles6667### Log Strategy6869| Log Type | Purpose |70|----------|---------|71| **Application logs** | Debug, audit |72| **Access logs** | Traffic analysis |73| **Error logs** | Issue detection |7475### Log Principles76771. **Rotate logs** to prevent disk fill782. **Structured logging** (JSON) for parsing793. **Appropriate levels** (error/warn/info/debug)804. **No sensitive data** in logs8182---8384## 4. Scaling Decisions8586### When to Scale8788| Symptom | Solution |89|---------|----------|90| High CPU | Add instances (horizontal) |91| High memory | Increase RAM or fix leak |92| Slow response | Profile first, then scale |93| Traffic spikes | Auto-scaling |9495### Scaling Strategy9697| Type | When to Use |98|------|-------------|99| **Vertical** | Quick fix, single instance |100| **Horizontal** | Sustainable, distributed |101| **Auto** | Variable traffic |102103---104105## 5. Health Check Principles106107### What Constitutes Healthy108109| Check | Meaning |110|-------|---------|111| **HTTP 200** | Service responding |112| **Database connected** | Data accessible |113| **Dependencies OK** | External services reachable |114| **Resources OK** | CPU/memory not exhausted |115116### Health Check Implementation117118- Simple: Just return 200119- Deep: Check all dependencies120- Choose based on load balancer needs121122---123124## 6. Security Principles125126| Area | Principle |127|------|-----------|128| **Access** | SSH keys only, no passwords |129| **Firewall** | Only needed ports open |130| **Updates** | Regular security patches |131| **Secrets** | Environment vars, not files |132| **Audit** | Log access and changes |133134---135136## 7. Troubleshooting Priority137138When something's wrong:1391401. **Check if running** (process status)1412. **Check logs** (error messages)1423. **Check resources** (disk, memory, CPU)1434. **Check network** (ports, DNS)1445. **Check dependencies** (database, APIs)145146---147148## 8. Anti-Patterns149150| ❌ Don't | ✅ Do |151|----------|-------|152| Run as root | Use non-root user |153| Ignore logs | Set up log rotation |154| Skip monitoring | Monitor from day one |155| Manual restarts | Auto-restart config |156| No backups | Regular backup schedule |157158---159160> **Remember:** A well-managed server is boring. That's the goal.161162## When to Use163This skill is applicable to execute the workflow or actions described in the overview.164165---166167> 🏰 **Rei Skills** — Curated by [Rootcastle Engineering & Innovation](https://www.rootcastle.com) | Batuhan Ayrıbaş 168> Engineering Beyond Boundaries | admin@rootcastle.com