System API Documentation

Provides API functions for system-level server interactions and information.

This module serves as an interface for querying system-related information about server processes and for managing their integration with the host operating system’s service management capabilities. It primarily orchestrates calls to the BedrockServer class.

Key functionalities include:
  • Querying server process resource usage (e.g., PID, CPU, memory) via get_bedrock_process_info().

  • Managing OS-level services (systemd on Linux, Windows Services on Windows) for servers, including creation (create_server_service()), enabling (enable_server_service()), and disabling (disable_server_service()) auto-start.

  • Configuring server-specific settings like autoupdate behavior via set_autoupdate().

These functions are designed for use by higher-level application components, such as the web UI or CLI, to provide system-level control and monitoring.

bedrock_server_manager.api.system.get_server_running_status(server_name: str, app_context: AppContext) Dict[str, Any]

Checks if the server process is currently running.

This function queries the operating system to determine if the Bedrock server process associated with the given server name is active by calling is_running().

Parameters:

server_name (str) – The name of the server to check.

Returns:

A dictionary with the operation result. On success: {"status": "success", "is_running": bool} (is_running is True if the process is active, False otherwise). On error: {"status": "error", "message": "<error_message>"}.

Return type:

Dict[str, Any]

Raises:
bedrock_server_manager.api.system.get_bedrock_process_info(server_name: str, app_context: AppContext) Dict[str, Any]

Retrieves resource usage for a running Bedrock server process.

This function queries the system for the server’s process by calling get_process_info() and returns details like PID, CPU usage, memory consumption, and uptime.

Parameters:

server_name (str) – The name of the server to query.

Returns:

A dictionary with the operation status and process information. On success with a running process: {"status": "success", "process_info": {"pid": int, "cpu_percent": float, "memory_mb": float, "uptime": str}}. If the process is not found or inaccessible: {"status": "success", "process_info": None, "message": "Server process '<name>' not found..."}. On error during retrieval: {"status": "error", "message": "<error_message>"}.

Return type:

Dict[str, Any]

Raises:
  • InvalidServerNameError – If server_name is not provided.

  • BSMError – Can be raised by BedrockServer instantiation if core application settings are misconfigured, or by get_process_info if psutil is unavailable or encounters issues.