Server States
Wings tracks server states using atomic strings to ensure thread-safe state management.Environment States
These are the core states defined inenvironment/environment.go:18-23:
Additional Operation States
Servers also track special operation states using atomic booleans:Installation Process
The installation process is a critical part of a server’s lifecycle. It prepares the server environment and runs setup scripts.Installation Flow
Installation Container Configuration
Installation runs in a temporary Docker container separate from the server’s runtime container:/mnt/server- Server’s data directory (read-write)/mnt/install- Installation script location (read-write)
Resource Limits During Installation
Installation containers use the higher of server limits or global installer limits:Power Actions
Power actions control the server’s running state. They are protected by an exclusive lock to prevent race conditions.Power Action Types
Start Process
Starting a server involves several pre-flight checks:Stop Process
Stopping can be done via command or signal, depending on server configuration:Restart Process
Restart is implemented as a stop followed by a start:Terminate Process
Termination bypasses the power lock for emergency situations:Crash Detection and Recovery
Wings includes automatic crash detection and restart capabilities.Crash Detection Logic
Crash Handler
The crash handler determines if a restart should occur:DetectCleanExitAsCrash- Whether exit code 0 counts as a crashTimeout- Minimum seconds between crashes to allow restart- Setting timeout to 0 always allows restart
State Change Events
State changes trigger events that can be subscribed to:Reinstallation
Reinstallation reruns the installation process without deleting server files:Transfer State
Servers being transferred between nodes have special state handling:- Server is marked as transferring
- Power actions are blocked
- Archive is created and sent to target node
- Target node extracts and starts server
Lifecycle Events Timeline
Next Steps
Architecture
Understand the overall system architecture
Docker Integration
Learn how Wings manages Docker containers
File Management
Explore filesystem operations
