Skip to main content
Wings provides comprehensive server lifecycle management through both API endpoints and internal processes.

Server Lifecycle

Server Structure

Each server instance in Wings is represented by the Server struct:
Source: server/server.go:28-80

Server States

Servers can be in one of several operational states:
  • ProcessOfflineState - Server is stopped
  • ProcessStartingState - Server is starting up
  • ProcessRunningState - Server is running
  • ProcessStoppingState - Server is shutting down
Source: environment/stats.go

Power Management

Power Actions

Wings supports four power actions:
Source: server/power.go:24-29

Executing Power Actions

Power actions are processed through a locking mechanism to prevent race conditions:
Features:
  • 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
Source: server/power.go:56-167

API Endpoint

Valid Actions: 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:
Source: server/power.go:171-219

Installation & Reinstallation

Installation Process

Servers are installed using Docker containers that run installation scripts:
Source: server/install.go:33-94

Installation Steps

  1. Fetch Installation Script - Retrieved from Panel
  2. Pull Container Image - Downloads Docker image for installer
  3. Write Script to Disk - Script written to temporary directory
  4. Create Container - Installation container created with:
    • Server files mounted at /mnt/server
    • Install script mounted at /mnt/install
    • Environment variables configured
  5. Execute Script - Container runs installation commands
  6. Stream Output - Console output streamed to websocket
  7. Cleanup - Container and temp files removed
Source: server/install.go:178-495

API Endpoints

Install Server

Triggers initial installation process. Source: router/router_server.go:153-169

Reinstall Server

Re-runs installation without removing existing files. Source: router/router_server.go:172-189

Installation Container Configuration

Source: server/install.go:399-413

Resource Limits

Installation containers use higher limits than server runtime:
Source: server/install.go:524-550

Console Access

Sending Commands

Commands can be sent to running servers:
Source: router/router_server.go:108-136

Reading Logs

Retrieve server console output:
Source: router/router_server.go:26-43

Console Throttling

Wings implements console output throttling to prevent spam:
When throttle is exceeded:
Source: server/console.go:46-83

Server Synchronization

Sync with Panel

Synchronize server configuration from Panel:
This endpoint:
  • Fetches latest configuration from Panel
  • Updates resource limits
  • Applies environment changes
  • Disconnects suspended servers
Source: router/router_server.go:142-150, server/server.go:186-216

Sync Process

Source: server/server.go:186-216

Environment Variables

Servers receive environment variables during startup:
Source: server/server.go:151-174

Server Deletion

Deletion process:
  1. Suspend server
  2. Notify websocket clients
  3. Stop running processes
  4. Remove from server manager
  5. Destroy environment
  6. Delete server files
Source: router/router_server.go:192-200

Error Handling

Common Errors

Power actions are blocked when server is:
  • Installing
  • Transferring to another node
  • Restoring from backup
Source: server/power.go:57-64