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_bedrock_process_info(server_name: str, app_context: AppContext | None = None) 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
BedrockServerinstantiation if core application settings are misconfigured, or byget_process_infoifpsutilis unavailable or encounters issues.
- bedrock_server_manager.api.system.set_autoupdate(server_name: str, autoupdate_value: str, app_context: AppContext | None = None) Dict[str, str]
Sets the ‘autoupdate’ flag in the server’s specific JSON configuration file.
This function modifies the server-specific JSON configuration file to enable or disable the automatic update check before the server starts, by calling
set_autoupdate(). Triggersbefore_autoupdate_changeandafter_autoupdate_changeplugin events.- Parameters:
server_name (str) – The name of the server.
autoupdate_value (str) – The desired state for autoupdate. Must be ‘true’ or ‘false’ (case-insensitive).
- Returns:
A dictionary with the operation result. On success:
{"status": "success", "message": "Autoupdate setting for '<name>' updated to <bool_value>."}On error:{"status": "error", "message": "<error_message>"}- Return type:
Dict[str, str]
- Raises:
InvalidServerNameError – If server_name is not provided.
MissingArgumentError – If autoupdate_value is not provided.
UserInputError – If autoupdate_value is not ‘true’ or ‘false’.
FileOperationError – If writing the server’s JSON configuration file fails.
ConfigParseError – If the server’s JSON configuration is malformed during load/save.
- bedrock_server_manager.api.system.set_autostart(server_name: str, autostart_value: str, app_context: AppContext | None = None) Dict[str, str]
Sets the ‘autostart’ flag in the server’s specific JSON configuration file.
This function modifies the server-specific JSON configuration file to enable or disable the automatic update check before the server starts, by calling
set_autostart(). Triggersbefore_autostart_changeandafter_autostart_changeplugin events.- Parameters:
server_name (str) – The name of the server.
autostart_value (str) – The desired state for autostart. Must be ‘true’ or ‘false’ (case-insensitive).
- Returns:
A dictionary with the operation result. On success:
{"status": "success", "message": "autostart setting for '<name>' updated to <bool_value>."}On error:{"status": "error", "message": "<error_message>"}- Return type:
Dict[str, str]
- Raises:
InvalidServerNameError – If server_name is not provided.
MissingArgumentError – If autostart_value is not provided.
UserInputError – If autostart_value is not ‘true’ or ‘false’.
FileOperationError – If writing the server’s JSON configuration file fails.
ConfigParseError – If the server’s JSON configuration is malformed during load/save.