server_commands
Main functions for instantiating and running Merlin server containers.
apply_config_changes(server_config, args)
Applies configuration changes to the Merlin server based on user-provided arguments.
This function modifies the Redis configuration and user settings as specified by the user through the provided arguments. It updates various Redis settings, such as IP address, port, password, directory, snapshot settings, append mode, and file paths. If any changes are made, the updated configuration is written to the appropriate files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_config
|
ServerConfig
|
An instance of |
required |
args
|
Namespace
|
An argparse |
required |
Source code in merlin/server/server_commands.py
check_for_not_running_server()
Checks if the Merlin server status is NOT_RUNNING before starting a new server.
If the server status is anything other than NOT_RUNNING, logs an appropriate
error message to inform the user.
Returns:
| Type | Description |
|---|---|
bool
|
True if the server status is |
Source code in merlin/server/server_commands.py
config_server(args)
Processes the Merlin server configuration flags to make changes and edits to appropriate configurations based on user input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
An argparse |
required |
Source code in merlin/server/server_commands.py
init_server()
Initializes the Merlin server by setting up the main configuration directory and local server configuration.
Source code in merlin/server/server_commands.py
restart_server()
Restarts a running Merlin server instance.
This function stops the currently running Merlin server and then starts it again. If the server is not running, it logs a message and returns False.
Returns:
| Type | Description |
|---|---|
bool
|
True if the server was successfully restarted, False otherwise. |
Source code in merlin/server/server_commands.py
server_started(process, server_config)
Verifies that the server started by start_container
is running properly.
This function checks the Redis output to ensure the server started successfully,
creates a process file for the container, and validates that the server status
is RUNNING.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process
|
Popen
|
The subprocess object representing the container
process started by |
required |
server_config
|
ServerConfig
|
An instance of |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the server started successfully, False otherwise. |
Source code in merlin/server/server_commands.py
start_container(server_config)
Starts a container based on the provided server configuration.
This function uses the server configuration to locate the necessary image and configuration files, validates their existence, and starts the container using a subprocess.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_config
|
ServerConfig
|
An instance of |
required |
Returns:
| Type | Description |
|---|---|
Popen
|
A subprocess object representing the running container process, or |
Source code in merlin/server/server_commands.py
start_server()
Starts a Merlin server container.
This function performs several steps to start the server, including checking
for an existing non-running server, pulling the server configuration, starting
the container, verifying the server startup, and applying Redis user and
configuration settings. It also generates a new app.yaml file for the server
configuration.
Returns:
| Type | Description |
|---|---|
bool
|
True if the server was successfully started, False otherwise. |
Source code in merlin/server/server_commands.py
status_server()
Retrieves and displays the current status of the Merlin server.
This function checks the status of any running containers for the Merlin server and logs appropriate messages based on the server's state.
Source code in merlin/server/server_commands.py
stop_server()
Stops a running Merlin server container.
This function checks the current server status, retrieves the server configuration, and attempts to terminate the running server process. If successful, the server process is stopped, and the function returns True. Otherwise, it logs errors and returns False.
Returns:
| Type | Description |
|---|---|
bool
|
True if the server was successfully stopped, False otherwise. |