Dependency library for game-server management applications.
Project description
Warlock Manager
Warlock Manager is a robust, extensible Python library for building game server management applications. It provides a comprehensive foundation for managing game applications, services, configurations, and server communications.
This is meant to be used with the Warlock Game Manager (Github Repo), but can be used independently.
Note: This is a dependency library designed to be integrated into game server manager applications. It is not intended to be used standalone.
Overview
Warlock Manager abstracts common game server management tasks, allowing you to build specialized manager applications for various games. It handles:
- Application Management: Base classes for managing game applications and multiple service instances
- Configuration Handling: Unified configuration system supporting multiple formats (INI, JSON, YAML, Properties, Unreal Engine)
- Service Management: Integration with systemd for service creation, control, and monitoring
- Network Communication: Multiple protocols (HTTP, RCON, Socket) for server interaction
- CLI Tools: Built-in CLI utilities for common operations
- TUI Interface: Terminal user interface components for interactive management
Features
Core Components
-
BaseApp: Abstract base for game application managers
- Multi-service instance support
- Service lifecycle management
- Configuration management
- Update handling
-
BaseService: Abstract base for game service instances
- systemd integration
- Configuration file management
- Port management and firewall integration
- Player count and status monitoring
- Backup and restore capabilities
- Command execution and API communication
-
Configuration System: Multiple configuration format support
BaseConfig: Abstract configuration handlerIniConfig: INI file supportJsonConfig: JSON file supportPropertiesConfig: Java properties file supportUnrealConfig: Unreal Engine configuration formatCliConfig: Command-line argument configuration
-
Service Protocols:
HttpService: HTTP-based server communicationRconService: RCON protocol supportSocketService: Unix socket-based communication
Utilities
- CLI Framework: Built on Typer for robust command-line interfaces
- Terminal UI: Menu systems and formatted output for interactive terminals
- Command Execution: Background and foreground process management
- Firewall Management: Automatic firewall rule configuration
- Port Management: Port discovery, allocation, and validation
- Data Filtering: Sensitive data masking for safe logging
Installation
Install as a dependency in your project:
pip install warlock-manager
Or add to your pyproject.toml:
[project]
dependencies = [
"warlock-manager>=2.1.0",
]
Or to your requirements.txt:
warlock-manager>=2.1.0
Requirements
- Python 3.10+
- Dependencies:
requests>=2.28- HTTP client librarypyyaml>=6.0- YAML parsingtyper>=0.24.1- CLI frameworkrcon>=2.4.9- RCON protocol supportsystemdunitparser>=0.4- systemd unit file parsingpackaging>=23.3- Version handlingpsutil>=7.2.0- System process utilities
Quick Start
Creating a Game Manager
For more detailed examples, check out the Warlock Game Template repository for a templated project you can fork and customize to quickly get started.
Extend BaseApp to create a manager for your game:
from warlock_manager.apps import BaseApp
from warlock_manager.services import BaseService
class MyGameApp(BaseApp):
def __init__(self):
super().__init__()
self.name = 'mygame'
self.desc = 'My Game Server'
self.service_prefix = 'mygame-'
def get_app_directory(self) -> str:
return '/var/games/mygame'
def detect_services(self) -> list:
# Detect existing game services
return []
def create_service(self, name: str) -> BaseService:
# Create and return a new service instance
pass
Creating a Game Service Handler
Extend BaseService to implement service-specific logic:
from warlock_manager.services import BaseService
from warlock_manager.config import IniConfig
class MyGameService(BaseService):
def __init__(self, service: str, game: BaseApp):
super().__init__(service, game)
# Configure configuration files
self.configs['game_config'] = IniConfig(
'/var/games/mygame/game.ini'
)
def get_port_definitions(self) -> list:
# Return list of port definitions: (port_number_or_config_key, 'tcp'/'udp', description)
return [
('game_port', 'tcp', 'Game Server Port'),
('query_port', 'udp', 'Query Port'),
]
def is_running(self) -> bool:
# Check if service is running
pass
Building a CLI Application
Use the built-in CLI framework:
from warlock_manager.libs.app_runner import app_runner
game = MyGameApp()
cli_app = app_runner(game)
if __name__ == '__main__':
cli_app()
This automatically provides commands for:
- Service management (start, stop, restart, status)
- Configuration management (get, set)
- Port discovery and management
- Metrics collection
- Backup and restore operations
- First-run setup
Additionally, the included TUI application as provided by app provides an interactive menu system for:
This provides an interactive menu system for:
- Viewing service status and metrics
- Managing service configurations
- Controlling service lifecycle
- Backup and data management
- Creating new service instances
Configuration
Configuration files can be defined through YAML (configs.yaml) in your application's scripts/ directory. Each configuration option specifies:
- Section: INI section or logical grouping
- Key: Configuration option name
- Default value
- Type: str, int, or bool
- Help text
- Display group
Example configs.yaml:
mygame:
- section: "Game Settings"
key: "server_name"
default: "My Server"
type: "str"
help: "The name of the game server"
group: Basic
- section: "Network"
key: "game_port"
default: "27015"
type: "int"
help: "Game server port"
group: Network
Features System
Control available functionality through the features system:
class MyGameApp(BaseApp):
def __init__(self):
super().__init__()
# Available features
self.features = {
'api', # Server API support
'cmd', # Command execution via API
'create_service', # Create new service instances
'mods', # Mod support
}
# Disable specific features
self.disabled_features = {'mods'}
Available features:
api- Server API communication supportcmd- Command execution capabilitiescreate_service- Ability to create new service instancesmods- Mod/plugin support
Development
Setting Up Development Environment
# Clone the repository
git clone https://github.com/BitsNBytes25/Warlock-Manager.git
cd warlock-manager
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install with development dependencies
pip install -e ".[dev]"
Running Tests
pytest
With coverage:
pytest --cov=warlock_manager
Code Quality
Run linting checks:
flake8 warlock_manager tests
API Reference
BaseApp
Main application class for game server management.
Key Methods:
detect_services(): Discover existing service instancescreate_service(name): Create a new service instanceget_services(): Get list of service instancesget_options(): Get application-level configuration optionsget_option_value(key): Get a configuration option valueset_option(key, value): Set a configuration optionstart_all(): Start all service instancesstop_all(): Stop all service instancesis_active(): Check if any service is runningupdate(): Update the application/game
BaseService
Service instance handler for individual game servers.
Key Methods:
load(): Load service configuration filesget_options(): Get service configuration optionsget_option_value(key): Get a configuration optionset_option(key, value): Set a configuration optionstart(): Start the servicestop(): Stop the servicerestart(): Restart the serviceis_running(): Check if service is runningget_port(): Get service's primary portget_ports(): Get all port definitionsis_enabled(): Check if auto-start is enabledcmd(command): Send command to serviceget_player_count(): Get current player countget_player_max(): Get max player capacitybackup(): Create backup of service datarestore(backup_path): Restore from backup
Configuration Classes
All configuration classes extend BaseConfig and provide:
load(): Load configuration from filesave(): Save configuration to fileget_option_value(key): Get option valueset_option_value(key, value): Set option valueexists(): Check if configuration file exists
License
This project is licensed under the GNU Affero General Public License v3.0 or later - see the LICENSE file for details.
Contributing
Contributions are welcome! Please ensure:
- Code follows PEP 8 style guidelines (checked with flake8)
- All tests pass (
pytest) - New features include appropriate tests
- Documentation is updated
Support
For issues, questions, and suggestions, please visit the project repository or refer to the documentation.
Built with ❤️ for game server administrators
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file warlock_manager-2.1.2.tar.gz.
File metadata
- Download URL: warlock_manager-2.1.2.tar.gz
- Upload date:
- Size: 83.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dd0023036ff7787817753d1ff8d5a6d07fb34117660d99b976b6d7ef5846943
|
|
| MD5 |
3e0718ceb73ad68d452ec7a6df77a502
|
|
| BLAKE2b-256 |
a52f3c73e88ac4edd68c079bf97f6e4082db01c1dbefe7fd2830344fa5c7848f
|
Provenance
The following attestation bundles were made for warlock_manager-2.1.2.tar.gz:
Publisher:
publish-to-pypi.yml on BitsNBytes25/Warlock-Manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
warlock_manager-2.1.2.tar.gz -
Subject digest:
6dd0023036ff7787817753d1ff8d5a6d07fb34117660d99b976b6d7ef5846943 - Sigstore transparency entry: 1191356044
- Sigstore integration time:
-
Permalink:
BitsNBytes25/Warlock-Manager@963ad2b921fd3c84eda6bb23546293e63298f428 -
Branch / Tag:
refs/tags/v2.1.2 - Owner: https://github.com/BitsNBytes25
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@963ad2b921fd3c84eda6bb23546293e63298f428 -
Trigger Event:
release
-
Statement type:
File details
Details for the file warlock_manager-2.1.2-py3-none-any.whl.
File metadata
- Download URL: warlock_manager-2.1.2-py3-none-any.whl
- Upload date:
- Size: 82.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0933b29f5ccb15ebb03eff98a28feb7eb99ead84e8d480b9c5c90b6e5b5d3bfa
|
|
| MD5 |
7c1a1908e4ebe42f48d4e5b835c38f41
|
|
| BLAKE2b-256 |
a36cc88c6855c5186ee007575d11e66c8a62fdd5dea952b9cb55217a58a6e1a0
|
Provenance
The following attestation bundles were made for warlock_manager-2.1.2-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on BitsNBytes25/Warlock-Manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
warlock_manager-2.1.2-py3-none-any.whl -
Subject digest:
0933b29f5ccb15ebb03eff98a28feb7eb99ead84e8d480b9c5c90b6e5b5d3bfa - Sigstore transparency entry: 1191356046
- Sigstore integration time:
-
Permalink:
BitsNBytes25/Warlock-Manager@963ad2b921fd3c84eda6bb23546293e63298f428 -
Branch / Tag:
refs/tags/v2.1.2 - Owner: https://github.com/BitsNBytes25
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@963ad2b921fd3c84eda6bb23546293e63298f428 -
Trigger Event:
release
-
Statement type: