domain

package
v0.0.0-...-15b5fa4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerNotInstalled = iota
	ServerInstalled
	ServerInstallInProcess
)
View Source
const AfterInstallScriptName = "gdaemon_after_install.sh"

Variables

View Source
var StartTime time.Time

Functions

func MakeFullCommand

func MakeFullCommand(
	cfg workDirReader,
	server *Server,
	commandTemplate string,
	serverCommand string,
) string

func ReplaceShortCodes

func ReplaceShortCodes(commandTemplate string, cfg workDirReader, server *Server) string

Types

type APIRequest

type APIRequest struct {
	Method      string
	URL         string
	Header      http.Header
	QueryParams map[string]string
	PathParams  map[string]string
	Body        []byte
}

type ErrInvalidResponseFromAPI

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

func NewErrInvalidResponseFromAPI

func NewErrInvalidResponseFromAPI(code int, response []byte) ErrInvalidResponseFromAPI

func (ErrInvalidResponseFromAPI) Error

func (err ErrInvalidResponseFromAPI) Error() string

type GDTask

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

func NewGDTask

func NewGDTask(
	id int,
	runAfterID int,
	server *Server,
	task GDTaskCommand,
	cmd string,
	status GDTaskStatus,
) *GDTask

func (*GDTask) Command

func (task *GDTask) Command() string

func (*GDTask) ID

func (task *GDTask) ID() int

func (*GDTask) IsComplete

func (task *GDTask) IsComplete() bool

func (*GDTask) IsInstallation

func (task *GDTask) IsInstallation() bool

func (*GDTask) IsWaiting

func (task *GDTask) IsWaiting() bool

func (*GDTask) IsWorking

func (task *GDTask) IsWorking() bool

func (*GDTask) RunAfterID

func (task *GDTask) RunAfterID() int

func (*GDTask) Server

func (task *GDTask) Server() *Server

func (*GDTask) SetStatus

func (task *GDTask) SetStatus(status GDTaskStatus) error

func (*GDTask) Status

func (task *GDTask) Status() GDTaskStatus

func (*GDTask) StatusNum

func (task *GDTask) StatusNum() uint8

func (*GDTask) Task

func (task *GDTask) Task() GDTaskCommand

type GDTaskCommand

type GDTaskCommand string
const (
	GDTaskGameServerStart     GDTaskCommand = "gsstart"
	GDTaskGameServerPause     GDTaskCommand = "gspause" // NOT Implemented
	GDTaskGameServerStop      GDTaskCommand = "gsstop"
	GDTaskGameServerKill      GDTaskCommand = "gskill" // NOT Implemented
	GDTaskGameServerRestart   GDTaskCommand = "gsrest"
	GDTaskGameServerInstall   GDTaskCommand = "gsinst"
	GDTaskGameServerReinstall GDTaskCommand = "gsreinst" // NOT Implemented
	GDTaskGameServerUpdate    GDTaskCommand = "gsupd"
	GDTaskGameServerDelete    GDTaskCommand = "gsdel"
	GDTaskGameServerMove      GDTaskCommand = "gsdel"
	GDTaskCommandExecute      GDTaskCommand = "cmdexec"
)

type GDTaskRepository

type GDTaskRepository interface {
	FindByStatus(ctx context.Context, status GDTaskStatus) ([]*GDTask, error)
	FindByID(ctx context.Context, id int) (*GDTask, error)
	Save(ctx context.Context, task *GDTask) error
	AppendOutput(ctx context.Context, gdtask *GDTask, output []byte) error
}

type GDTaskStats

type GDTaskStats struct {
	WorkingCount int
	WaitingCount int
}

type GDTaskStatsReader

type GDTaskStatsReader interface {
	Stats() GDTaskStats
}

type GDTaskStatus

type GDTaskStatus string
const (
	GDTaskStatusWaiting  GDTaskStatus = "waiting"
	GDTaskStatusWorking  GDTaskStatus = "working"
	GDTaskStatusError    GDTaskStatus = "error"
	GDTaskStatusSuccess  GDTaskStatus = "success"
	GDTaskStatusCanceled GDTaskStatus = "canceled"
)

type Game

type Game struct {
	Code              string     `json:"code"`
	StartCode         string     `json:"start_code"`
	Name              string     `json:"name"`
	Engine            string     `json:"engine"`
	EngineVersion     string     `json:"engine_version"`
	SteamAppSetConfig string     `json:"steam_app_set_config"`
	RemoteRepository  string     `json:"remote_repository"`
	LocalRepository   string     `json:"local_repository"`
	SteamAppID        SteamAppID `json:"steam_app_id"`
}

type GameMod

type GameMod struct {
	Name                   string               `json:"name"`
	RemoteRepository       string               `json:"remote_repository"`
	LocalRepository        string               `json:"local_repository"`
	DefaultStartCMDLinux   string               `json:"default_start_cmd_linux"`
	DefaultStartCMDWindows string               `json:"default_start_cmd_windows"`
	Vars                   []GameModVarTemplate `json:"vars"`
	ID                     int                  `json:"id"`
}

type GameModVarTemplate

type GameModVarTemplate struct {
	Key          string
	DefaultValue string
}

func (*GameModVarTemplate) UnmarshalJSON

func (g *GameModVarTemplate) UnmarshalJSON(bytes []byte) error

type InstallationStatus

type InstallationStatus int

type Result

type Result int
const (
	UnknownResult Result = -1
	SuccessResult Result = 0
	ErrorResult   Result = 1
)

type Server

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

func NewServer

func NewServer(
	id int,
	enabled bool,
	installStatus InstallationStatus,
	blocked bool,
	name string,
	uuid string,
	uuidShort string,
	game Game,
	gameMod GameMod,
	ip string,
	connectPort int,
	queryPort int,
	rconPort int,
	rconPassword string,
	dir string,
	user string,
	startCommand string,
	stopCommand string,
	forceStopCommand string,
	restartCommand string,
	processActive bool,
	lastProcessCheck time.Time,
	vars map[string]string,
	settings Settings,
	updatedAt time.Time,
) *Server

func (*Server) AffectInstall

func (s *Server) AffectInstall()

func (*Server) AffectStart

func (s *Server) AffectStart()

func (*Server) AffectStop

func (s *Server) AffectStop()

func (*Server) AutoStart

func (s *Server) AutoStart() bool

func (*Server) Blocked

func (s *Server) Blocked() bool

func (*Server) ConnectPort

func (s *Server) ConnectPort() int

func (*Server) Dir

func (s *Server) Dir() string

func (*Server) Enabled

func (s *Server) Enabled() bool

func (*Server) Game

func (s *Server) Game() Game

func (*Server) GameMod

func (s *Server) GameMod() GameMod

func (*Server) ID

func (s *Server) ID() int

func (*Server) IP

func (s *Server) IP() string

func (*Server) InstallationStatus

func (s *Server) InstallationStatus() InstallationStatus

func (*Server) IsActive

func (s *Server) IsActive() bool

func (*Server) IsModified

func (s *Server) IsModified() bool

func (*Server) IsValueModified

func (s *Server) IsValueModified(key string) bool

func (*Server) LastStatusCheck

func (s *Server) LastStatusCheck() time.Time

func (*Server) LastTaskCompletedAt

func (s *Server) LastTaskCompletedAt() time.Time

func (*Server) NoticeTaskCompleted

func (s *Server) NoticeTaskCompleted()

func (*Server) QueryPort

func (s *Server) QueryPort() int

func (*Server) RCONPassword

func (s *Server) RCONPassword() string

func (*Server) RCONPort

func (s *Server) RCONPort() int

func (*Server) RestartCommand

func (s *Server) RestartCommand() string

func (*Server) Set

func (s *Server) Set(
	enabled bool,
	installStatus InstallationStatus,
	blocked bool,
	name string,
	uuid string,
	uuidShort string,
	game Game,
	gameMod GameMod,
	ip string,
	connectPort int,
	queryPort int,
	rconPort int,
	rconPassword string,
	dir string,
	user string,
	startCommand string,
	stopCommand string,
	forceStopCommand string,
	restartCommand string,
	processActive bool,
	lastProcessCheck time.Time,
	vars map[string]string,
	settings Settings,
	updatedAt time.Time,
)

func (*Server) SetInstallationStatus

func (s *Server) SetInstallationStatus(status InstallationStatus)

func (*Server) SetSetting

func (s *Server) SetSetting(key string, value string)

func (*Server) SetStatus

func (s *Server) SetStatus(processActive bool)

func (*Server) Setting

func (s *Server) Setting(key string) string

func (*Server) StartCommand

func (s *Server) StartCommand() string

func (*Server) StopCommand

func (s *Server) StopCommand() string

func (*Server) UUID

func (s *Server) UUID() string

func (*Server) UUIDShort

func (s *Server) UUIDShort() string

func (*Server) UnmarkModifiedFlag

func (s *Server) UnmarkModifiedFlag()

func (*Server) UpdateBeforeStart

func (s *Server) UpdateBeforeStart() bool

func (*Server) UpdatedAt

func (s *Server) UpdatedAt() time.Time

func (*Server) User

func (s *Server) User() string

func (*Server) Vars

func (s *Server) Vars() map[string]string

func (*Server) WorkDir

func (s *Server) WorkDir(cfg workDirReader) string

type ServerCommand

type ServerCommand int
const (
	Start ServerCommand = iota + 1
	Pause
	Unpause
	Status
	Stop
	Kill
	Restart
	Update
	Install
	Reinstall
	Delete
)

type ServerRepository

type ServerRepository interface {
	IDs(ctx context.Context) ([]int, error)
	FindByID(ctx context.Context, id int) (*Server, error)
	Save(ctx context.Context, task *Server) error
}

type ServerTask

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

func NewServerTask

func NewServerTask(
	id int,
	command ServerTaskCommand,
	server *Server,
	repeat int,
	repeatPeriod time.Duration,
	counter int,
	executeDate time.Time,
) *ServerTask

func (*ServerTask) CanExecute

func (s *ServerTask) CanExecute() bool

func (*ServerTask) Command

func (s *ServerTask) Command() ServerTaskCommand

func (*ServerTask) Counter

func (s *ServerTask) Counter() int

func (*ServerTask) ExecuteDate

func (s *ServerTask) ExecuteDate() time.Time

func (*ServerTask) ID

func (s *ServerTask) ID() int

func (*ServerTask) IncreaseCountersAndTime

func (s *ServerTask) IncreaseCountersAndTime()

func (ServerTask) MarshalJSON

func (s ServerTask) MarshalJSON() ([]byte, error)

func (*ServerTask) Repeat

func (s *ServerTask) Repeat() int

func (*ServerTask) RepeatEndlessly

func (s *ServerTask) RepeatEndlessly() bool

func (*ServerTask) RepeatPeriod

func (s *ServerTask) RepeatPeriod() time.Duration

func (*ServerTask) Server

func (s *ServerTask) Server() *Server

func (*ServerTask) Status

func (s *ServerTask) Status() ServerTaskStatus

type ServerTaskCommand

type ServerTaskCommand string
const (
	ServerTaskStart     ServerTaskCommand = "start"
	ServerTaskStop      ServerTaskCommand = "stop"
	ServerTaskRestart   ServerTaskCommand = "restart"
	ServerTaskUpdate    ServerTaskCommand = "update"
	ServerTaskReinstall ServerTaskCommand = "reinstall"
)

type ServerTaskRepository

type ServerTaskRepository interface {
	Find(ctx context.Context) ([]*ServerTask, error)
	Save(ctx context.Context, task *ServerTask) error
	Fail(ctx context.Context, task *ServerTask, output []byte) error
}

type ServerTaskStatus

type ServerTaskStatus int
const (
	ServerTaskStatusWaiting ServerTaskStatus = iota
	ServerTaskStatusWorking
	ServerTaskStatusSuccess
	ServerTaskStatusFail
)

type Settings

type Settings map[string]string

Settings are impact on server management by daemon.

type SteamAppID

type SteamAppID int

func (SteamAppID) String

func (appID SteamAppID) String() string

func (*SteamAppID) UnmarshalJSON

func (appID *SteamAppID) UnmarshalJSON(bytes []byte) error

type SteamSettings

type SteamSettings struct {
	AppSetConfig string
}

Jump to

Keyboard shortcuts

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