spawner

package
v0.0.0-...-9022a88 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_PORT uint32 = 3002

Variables

This section is empty.

Functions

func LaunchGameServer

func LaunchGameServer(config *Config, port uint32) (*os.Process, error)

LaunchGameServer execs the game server subprocess on the given port. The Process pointer representing the new process is returned.

Types

type Config

type Config struct {
	SupportedGameID shared.GameIDType `json:"supportedGameId"`
	MaxGameServers  uint32            `json:"maxGameServers"`
	GameServerPath  string            `json:"gameServerPath"`
	GameServerFlags []string          `json:"gameServerFlags"`

	// Whether the spawner should start game servers immediately, versus
	// waiting for clients to request spawns.
	Autorun bool `json:"autorun"`

	// The internet hostname that the spawner and gameservers are running on.
	// This can be left empty, and the master server will infer host automatically.
	// However, for a single docker network stack, this is a bad idea because
	// the master server will discover the docker IP for the spawner rather than
	// the public IP. So, the best practice is to always set this.
	Host string `json:"host"`

	// Port that the spawner is running on.
	Port uint32 `json:"port"`
}

Config contains global configuration for the hotel spawner instance. The configuration is loaded from a JSON file provided at runtime.

func LoadConfig

func LoadConfig(configPath string) Config

LoadConfig loads and returns a spawner config from the given path.

type MasterClient

type MasterClient struct {
	Addr string
}

MasterClient manages the RPC connection to the master server.

func NewMasterClient

func NewMasterClient(addr string) MasterClient

NewMasterClient initializes and returns a MasterClient.

func (*MasterClient) Register

func (c *MasterClient) Register(port uint32, spawnerStatus hotel_pb.SpawnerStatus) error

Register makes an RPC to the master server to register this spawner instance.

type ServerController

type ServerController struct {
	// contains filtered or unexported fields
}

ServerController manages the lifecycle of game server processes.

func NewServerController

func NewServerController(config *Config) *ServerController

NewServerController initializes and returns a ServerController.

func (*ServerController) Capacity

func (c *ServerController) Capacity() int

Capacity returns the number of available server slots on this instance.

func (*ServerController) NumRunningServers

func (c *ServerController) NumRunningServers() int

NumRunningServers returns the number of currently running game serfvers.

func (*ServerController) SpawnServer

func (c *ServerController) SpawnServer() (uint32, error)

SpawnServer attempts to spawn a server process and return its port.

type SpawnerService

type SpawnerService struct {
	// contains filtered or unexported fields
}

SpawnerService contains RPC implementations for the spawner service.

func NewSpawnerService

func NewSpawnerService(config *Config, controller *ServerController) SpawnerService

NewSpawnerService creates and initializes a SpawnerService.

func (*SpawnerService) CheckStatus

CheckStatus returns the current status via RPC.

func (*SpawnerService) GetStatus

func (s *SpawnerService) GetStatus() hotel_pb.SpawnerStatus

GetStatus returns the status proto representing the current status of the spawner.

func (*SpawnerService) SpawnServer

SpawnServer attempts to spawn a game server via the incoming RPC request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL