System Overview
Wings operates as a standalone daemon that communicates with both the Pterodactyl Panel and Docker. It serves as the bridge that translates panel commands into container operations.Core Components
Server Manager
The Server Manager (server/manager.go:25-283) is the central orchestrator for all server instances on a Wings node.
- Maintains a collection of all server instances
- Initializes servers from Panel API data
- Provides thread-safe access to server instances
- Persists server states to disk
HTTP Router
The router (router/router.go:14-115) defines all API endpoints and middleware that Wings exposes.
Endpoint Categories:
-
Signed URLs (no authentication required)
/download/backup- Download server backups/download/file- Download server files/upload/file- Upload files to servers
-
WebSocket (JWT authentication)
/api/servers/:server/ws- Real-time console access
-
Protected API (token authentication)
- System information
- Server management (CRUD operations)
- Power actions
- File operations
- Backup management
Server Instance
Each server is represented by aServer struct (server/server.go:28-80) that encapsulates all server-specific state and operations.
- Each server has its own context for cancellation
- Thread-safe atomic booleans track ongoing operations
- Event bus for publishing state changes
Communication Patterns
Panel to Wings
Wings acts as an HTTP server that the Panel communicates with via REST API. Authentication:- Panel sends authenticated HTTP request to Wings
- Middleware validates authentication token
- Middleware checks if server exists (for server-specific endpoints)
- Request handler executes the operation
- Response is returned to Panel
Wings to Panel
Wings communicates back to the Panel for:- Fetching server configurations
- Reporting installation status
- Validating SFTP credentials
- Sending activity logs
Wings to Docker
Wings uses the Docker client library to manage containers. Connection:ContainerCreate- Create new containersContainerStart- Start containersContainerStop- Stop containers gracefullyContainerKill- Forcefully terminate containersContainerAttach- Attach to container I/O streamsContainerInspect- Get container state information
Data Flow Example
Here’s how a server start request flows through the system:Concurrency and Safety
Power Action Locking
Power actions use an exclusive lock to prevent race conditions:Server Manager Thread Safety
The manager uses read-write mutexes for concurrent access:Atomic State Tracking
Server states use atomic values to avoid race conditions:Configuration Syncing
Servers sync their configuration with the Panel at critical points:- On Startup - When Wings boots, all servers fetch latest config
- Before Start - Ensures latest settings before booting server
- On Explicit Sync - Manual sync operations from Panel
State Persistence
Wings persists server states to disk to survive restarts:Next Steps
Server Lifecycle
Learn about server states and transitions
Docker Integration
Understand how Wings uses Docker
File Management
Explore filesystem operations
