service

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SettingsDirectory = "/opt/factorio/settings"
	FactOpSettings    = SettingsDirectory + "/factop-settings.json"
	ServerSettings    = SettingsDirectory + "/server-settings.json"
	ServerAdminList   = SettingsDirectory + "/server-adminlist.json"
	ServerBanList     = SettingsDirectory + "/server-banlist.json"
)
View Source
const CreateSaveOutput = SaveLocation + "/create-save.log"
View Source
const CurrentSoftMod = SaveLocation + "/softmod.zip"
View Source
const FactorioBinary = FactorioDirectory + "/bin/x64/factorio"
View Source
const FactorioDirectory = "/opt/factorio/current"
View Source
const NewLine = "\n"
View Source
const NewSave = SaveLocation + "/newSave.zip"
View Source
const RconStartupMarker = "Starting RCON interface at IP ADDR"
View Source
const SaveFile = SaveLocation + "/save.zip"
View Source
const SaveLocation = "/opt/factorio/saves"

Variables

View Source
var IgnorePattern = regexp.MustCompile(`(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) \[(\w+)] (.+)`)

Functions

func New

func New() servicego.Service

func Run

func Run()

Types

type Command

type Command struct {
	servicego.DefaultLogger
	Factorio *Factorio
}

func (*Command) Execute

func (c *Command) Execute(ctx context.Context, req *api.CommandPayload) (*api.CommandResult, error)

func (*Command) Start

func (c *Command) Start(s *Service) error

func (*Command) Stop

func (c *Command) Stop() error

type Component

type Component interface {
	Start(service *Service) error
	Stop() error
}

type ComponentTemplate

type ComponentTemplate struct {
	servicego.DefaultLogger
}

ComponentTemplate is a template for creating new components

func (*ComponentTemplate) Start

func (c *ComponentTemplate) Start(s *Service) error

func (*ComponentTemplate) Stop

func (c *ComponentTemplate) Stop() error

type Factorio

type Factorio struct {
	servicego.Defaults
	Nats *Nats

	Port         int
	RconBind     string
	RconPassword string
	// contains filtered or unexported fields
}

func (*Factorio) Reset

func (f *Factorio) Reset() error

func (*Factorio) Restart

func (f *Factorio) Restart() error

func (*Factorio) Start

func (f *Factorio) Start(s *Service) error

func (*Factorio) Status

func (f *Factorio) Status() string

func (*Factorio) Stop

func (f *Factorio) Stop() error

type Nats

type Nats struct {
	servicego.DefaultLogger
	// contains filtered or unexported fields
}

func (*Nats) Publish

func (n *Nats) Publish(s string, bytes []byte)

func (*Nats) PublishMsg

func (n *Nats) PublishMsg(m *nats.Msg)

func (*Nats) Start

func (n *Nats) Start(l *Service) error

func (*Nats) Stop

func (n *Nats) Stop() error

func (*Nats) Subscribe

func (n *Nats) Subscribe(subject string, handler nats.MsgHandler) error

type Rcon

type Rcon struct {
	servicego.DefaultLogger
	Factorio *Factorio
	// contains filtered or unexported fields
}

func (*Rcon) Execute

func (r *Rcon) Execute(_ context.Context, req *api.RconCommand) (*api.RconResult, error)

func (*Rcon) Start

func (r *Rcon) Start(s *Service) error

func (*Rcon) Stop

func (r *Rcon) Stop() error

type Service

type Service struct {
	servicego.Defaults

	Nats      *Nats
	Settings  *Settings
	Factorio  *Factorio
	Rcon      *Rcon
	SoftMod   *SoftMod
	Command   *Command
	WebServer *WebServer
	// contains filtered or unexported fields
}

func (*Service) Start

func (sv *Service) Start(s kservice.Service) error

func (*Service) Stop

func (sv *Service) Stop(_ kservice.Service) error

type Settings

type Settings struct {
	servicego.DefaultLogger
}

func (*Settings) ServerAdmins

func (s *Settings) ServerAdmins(ctx context.Context, req *api.ServerAdminsType) (*api.ServerAdminsType, error)

func (*Settings) Start

func (s *Settings) Start(service *Service) error

func (*Settings) Stop

func (s *Settings) Stop() error

type SoftMod

type SoftMod struct {
	servicego.DefaultLogger
	Factorio *Factorio
	Service  *Service
}

func (*SoftMod) ApplySoftMod

func (sm *SoftMod) ApplySoftMod(_ context.Context, req *api.SoftModRequest) (*api.Empty, error)

func (*SoftMod) Start

func (sm *SoftMod) Start(s *Service) error

func (*SoftMod) Stop

func (sm *SoftMod) Stop() error

type WebServer

type WebServer struct {
	servicego.DefaultLogger
	// contains filtered or unexported fields
}

func (*WebServer) ServeHTTP

func (w *WebServer) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*WebServer) Start

func (w *WebServer) Start(s *Service) error

func (*WebServer) Stop

func (w *WebServer) Stop() error

Jump to

Keyboard shortcuts

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