Source code for acore_server_bootstrap.cli.main
# -*- coding: utf-8 -*-
"""
todo: docstring
"""
import fire
from acore_server.api import Server
from .. import api
from ..logger import logger
[docs]class Command:
"""
acore server bootstrap command line interface.
"""
[docs] @logger.pretty_log()
def bootstrap_as_sudo(self):
"""
Bootstrap a new EC2 server, run automations that requires sudo.
"""
with logger.nested():
api.disable_ubuntu_auto_upgrade()
api.setup_ec2_run_on_restart_script()
[docs] @logger.pretty_log()
def bootstrap(self):
"""
Bootstrap a new EC2 server, run automations that doesn't require sudo.
"""
with logger.nested():
server = Server.from_ec2_inside()
api.configure_db(server)
api.apply_server_config(server)
api.run_log_to_ec2_tag_cron_job()
api.run_measure_worldserver_cron_job()
api.run_server()
[docs] def disable_ubuntu_auto_upgrade(self):
"""
Disable Ubuntu auto upgrade (don't upgrade mysql).
"""
api.disable_ubuntu_auto_upgrade()
[docs] def setup_ec2_run_on_restart_script(self):
"""
Setup cloud init script to run on restart.
"""
api.setup_ec2_run_on_restart_script()
[docs] def create_database(self):
"""
Create the database user for game server and three initial databases.
"""
server = Server.from_ec2_inside()
api.create_database(server)
[docs] def create_user(self):
"""
Create the database user for game server.
"""
server = Server.from_ec2_inside()
api.create_user(server)
[docs] def update_realmlist(self):
"""
Update 'acore_auth.realmlist.address'.
"""
server = Server.from_ec2_inside()
api.update_realmlist(server)
[docs] def configure_db(self):
"""
Configure the database for game server.
"""
server = Server.from_ec2_inside()
api.configure_db(server)
[docs] def apply_authserver_conf(self):
"""
Update the authserver.conf.
"""
server = Server.from_ec2_inside()
api.apply_authserver_conf(server)
[docs] def apply_worldserver_conf(self):
"""
Update the worldserver.conf.
"""
server = Server.from_ec2_inside()
api.apply_worldserver_conf(server)
[docs] def apply_mod_lua_engine_conf(self):
"""
Update the mod_LuaEngine.conf.
"""
server = Server.from_ec2_inside()
api.apply_mod_lua_engine_conf(server)
[docs] def apply_server_config(self):
"""
Update the authserver.conf, worldserver.conf and mod_LuaEngine.conf.
"""
server = Server.from_ec2_inside()
api.apply_server_config(server)
def sync_lua_scripts(self, s3dir_uri: str):
api.sync_lua_scripts(s3dir_uri=s3dir_uri)
[docs] def run_check_server_status_cron_job(self):
"""
Run the "check server status" cron job in screen session.
"""
api.run_check_server_status_cron_job()
[docs] def stop_check_server_status_cron_job(self):
"""
Stop the "check server status" cron job.
"""
api.stop_check_server_status_cron_job()
[docs] def run_log_to_ec2_tag_cron_job(self):
"""
Run the "log to ec2 tag" cron job in screen session.
"""
api.run_log_to_ec2_tag_cron_job()
[docs] def stop_log_to_ec2_tag_cron_job(self):
"""
Stop the "log to ec2 tag" cron job.
"""
api.stop_log_to_ec2_tag_cron_job()
[docs] def run_measure_worldserver_cron_job(self):
"""
Run the "measure worldserver" cron job in screen session.
"""
api.run_measure_worldserver_cron_job()
[docs] def stop_measure_worldserver_cron_job(self):
"""
Stop the "measure worldserver" cron job.
"""
api.stop_measure_worldserver_cron_job()
[docs] def enter_worldserver(self):
"""
Enter the worldserver screen session.
"""
api.enter_worldserver()
def run():
fire.Fire(Command)