Server Lifecycle
Server Structure
Each server instance in Wings is represented by theServer struct:
server/server.go:28-80
Server States
Servers can be in one of several operational states:ProcessOfflineState- Server is stoppedProcessStartingState- Server is starting upProcessRunningState- Server is runningProcessStoppingState- Server is shutting down
environment/stats.go
Power Management
Power Actions
Wings supports four power actions:server/power.go:24-29
Executing Power Actions
Power actions are processed through a locking mechanism to prevent race conditions:- Exclusive lock prevents concurrent power actions
- Configurable wait timeout for lock acquisition
- Terminate action bypasses lock for emergency stops
- Blocks actions during install/transfer/restore operations
server/power.go:56-167
API Endpoint
start, stop, restart, kill
Wait Seconds: Time to wait for power lock (0-300 seconds, default 30)
Source: router/router_server.go:53-105
Pre-Start Process
Before starting a server, Wings performs several checks:server/power.go:171-219
Installation & Reinstallation
Installation Process
Servers are installed using Docker containers that run installation scripts:server/install.go:33-94
Installation Steps
- Fetch Installation Script - Retrieved from Panel
- Pull Container Image - Downloads Docker image for installer
- Write Script to Disk - Script written to temporary directory
- Create Container - Installation container created with:
- Server files mounted at
/mnt/server - Install script mounted at
/mnt/install - Environment variables configured
- Server files mounted at
- Execute Script - Container runs installation commands
- Stream Output - Console output streamed to websocket
- Cleanup - Container and temp files removed
server/install.go:178-495
API Endpoints
Install Server
router/router_server.go:153-169
Reinstall Server
router/router_server.go:172-189
Installation Container Configuration
server/install.go:399-413
Resource Limits
Installation containers use higher limits than server runtime:server/install.go:524-550
Console Access
Sending Commands
Commands can be sent to running servers:router/router_server.go:108-136
Reading Logs
Retrieve server console output:router/router_server.go:26-43
Console Throttling
Wings implements console output throttling to prevent spam:server/console.go:46-83
Server Synchronization
Sync with Panel
Synchronize server configuration from Panel:- Fetches latest configuration from Panel
- Updates resource limits
- Applies environment changes
- Disconnects suspended servers
router/router_server.go:142-150, server/server.go:186-216
Sync Process
server/server.go:186-216
Environment Variables
Servers receive environment variables during startup:server/server.go:151-174
Server Deletion
- Suspend server
- Notify websocket clients
- Stop running processes
- Remove from server manager
- Destroy environment
- Delete server files
router/router_server.go:192-200
Error Handling
Common Errors
- Installing
- Transferring to another node
- Restoring from backup
server/power.go:57-64