server#

See Server for more details.

class acore_server.server.Server(config: Server, metadata: Server)[source]#

A data container that holds both the config and metadata of a server.

Usage:

# if you are on develop's laptop or lambda
>>> server = Server.get(bsm=..., server_id="sbx-blue", ...)
# if you are on game server EC2
>>> server = Server.from_ec2_inside()

Server operation methods:

  • Server.run_ec2 <acore_server.server_operation_mixin.ServerOperationMixin.run_ec2()

  • Server.run_rds <acore_server.server_operation_mixin.ServerOperationMixin.run_rds()

  • Server.start_ec2 <acore_server.server_operation_mixin.ServerOperationMixin.start_ec2()

  • Server.start_rds <acore_server.server_operation_mixin.ServerOperationMixin.start_rds()

  • Server.associate_eip_address <acore_server.server_operation_mixin.ServerOperationMixin.associate_eip_address()

  • Server.update_db_master_password <acore_server.server_operation_mixin.ServerOperationMixin.update_db_master_password()

  • Server.stop_ec2 <acore_server.server_operation_mixin.ServerOperationMixin.stop_ec2()

  • Server.stop_rds <acore_server.server_operation_mixin.ServerOperationMixin.stop_rds()

  • Server.delete_ec2 <acore_server.server_operation_mixin.ServerOperationMixin.delete_ec2()

  • Server.delete_rds <acore_server.server_operation_mixin.ServerOperationMixin.delete_rds()

  • Server.bootstrap <acore_server.server_operation_mixin.ServerOperationMixin.bootstrap()

  • Server.run_server <acore_server.server_operation_mixin.ServerOperationMixin.run_server()

  • Server.stop_server <acore_server.server_operation_mixin.ServerOperationMixin.stop_server()

  • Server.count_online_player <acore_server.server_operation_mixin.ServerOperationMixin.count_online_player()

  • Server.create_ssh_tunnel <acore_server.server_operation_mixin.ServerOperationMixin.create_ssh_tunnel()

  • Server.list_ssh_tunnel <acore_server.server_operation_mixin.ServerOperationMixin.list_ssh_tunnel()

  • Server.test_ssh_tunnel <acore_server.server_operation_mixin.ServerOperationMixin.test_ssh_tunnel()

  • Server.kill_ssh_tunnel <acore_server.server_operation_mixin.ServerOperationMixin.kill_ssh_tunnel()

Parameters:
classmethod get(bsm: BotoSesManager, server_id: str, parameter_name_prefix: Optional[str] = Sentinel('NOTHING'), s3folder_config: Optional[str] = Sentinel('NOTHING'))[source]#

指定一个 server_id, 读取它的 config 和 metadata, 然后返回一个 Server 对象.

Parameters:
classmethod from_ec2_inside()[source]#

用 “自省” 的方式从 EC2 instance 里面读取 server_id, 读取 config 和 metadata, 然后返回一个 Server 对象.

property id: str#

Server id, the naming convention is ${env_name}-${server_name}

property env_name: str#

Environment name, e.g. sbx, tst, prd.

property server_name: str#

Server name, e.g. blue, green.