Skip to main content
A Pterodactyl server instance goes through multiple states throughout its lifecycle, from installation to deletion. Understanding these states and transitions is crucial for developing integrations and troubleshooting issues.

Server States

Wings tracks server states using atomic strings to ensure thread-safe state management.

Environment States

These are the core states defined in environment/environment.go:18-23:
State Diagram:

Additional Operation States

Servers also track special operation states using atomic booleans:
These prevent conflicting operations from running simultaneously.

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:
Key Mounts:
  • /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:
This prevents servers with very low limits from failing installation while avoiding excessive resource usage.

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:
Termination sends SIGKILL to immediately stop the container:

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:
Crash Detection Configuration:
  • DetectCleanExitAsCrash - Whether exit code 0 counts as a crash
  • Timeout - 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:
During transfers:
  • 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