service

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SettingsDirectory  = "/opt/factorio/settings"
	FactOpSettingsPath = SettingsDirectory + "/factop-settings.json"
	ServerSettings     = SettingsDirectory + "/server-settings.json"
	MapGenSettings     = SettingsDirectory + "/map-gen-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 DefaultShutdownTimeout = 30 * time.Second
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 Run

func Run()

Types

type Command

type Command struct {
	slog.Logger
	Nats     *Nats
	Factorio *Factorio
	Settings *Settings
}

func (*Command) Startup added in v0.1.0

func (c *Command) Startup() error

type ComponentTemplate

type ComponentTemplate struct {
	slog.Logger
}

ComponentTemplate is a template for creating new components

func (*ComponentTemplate) Shutdown added in v0.1.0

func (c *ComponentTemplate) Shutdown() error

func (*ComponentTemplate) Startup added in v0.1.0

func (c *ComponentTemplate) Startup() error

type FactOpSettings

type FactOpSettings struct {
	Port            string `json:"Port,omitzero"`
	SaveLocation    string `json:"SaveLocation,omitzero"`
	FactorioVersion string `json:"FactorioVersion,omitzero"`
	GamePort        int    `json:"GamePort,omitzero"`
	RconBind        string `json:"RconBind,omitzero"`
	UDPIncoming     int    `json:"UDPIncoming,omitzero"`
	UDPOutgoing     int    `json:"UDPOutgoing,omitzero"`
}

type Factorio

type Factorio struct {
	slog.Logger
	Nats     *Nats
	SoftMod  *SoftMod
	Settings *Settings

	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) Shutdown added in v0.1.0

func (f *Factorio) Shutdown() error

func (*Factorio) Start

func (f *Factorio) Start() error

func (*Factorio) Startup added in v0.1.0

func (f *Factorio) Startup() error

func (*Factorio) Status

func (f *Factorio) Status() string

type LogHandler added in v0.1.0

type LogHandler struct {
	Logger service.Logger
	// contains filtered or unexported fields
}

func (*LogHandler) ClearNatsConn added in v0.1.4

func (s *LogHandler) ClearNatsConn()

func (*LogHandler) Enabled added in v0.1.0

func (s *LogHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*LogHandler) Handle added in v0.1.0

func (s *LogHandler) Handle(ctx context.Context, record slog.Record) error

func (*LogHandler) SetNatsConn added in v0.1.4

func (s *LogHandler) SetNatsConn(conn *nats.Conn)

func (*LogHandler) WithAttrs added in v0.1.0

func (s *LogHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*LogHandler) WithGroup added in v0.1.0

func (s *LogHandler) WithGroup(name string) slog.Handler

type Nats

type Nats struct {
	slog.Logger
	LogHandler *LogHandler
	// 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) Reply added in v0.1.0

func (n *Nats) Reply(in *nats.Msg, payload []byte, err error)

func (*Nats) Shutdown added in v0.1.0

func (n *Nats) Shutdown() error

func (*Nats) Startup added in v0.1.0

func (n *Nats) Startup() error

func (*Nats) Subscribe

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

type Rcon

type Rcon struct {
	slog.Logger
	Nats     *Nats
	Factorio *Factorio
	// contains filtered or unexported fields
}

func (*Rcon) Shutdown added in v0.1.0

func (r *Rcon) Shutdown() error

func (*Rcon) Startup added in v0.1.0

func (r *Rcon) Startup() error

type ServerState added in v0.1.4

type ServerState int

ServerState represents the lifecycle state of the Factorio server process.

const (
	StateStopped  ServerState = iota // No process running
	StateStarting                    // cmd.Start() called, waiting for RCON marker
	StateRunning                     // RCON marker detected, server accepting commands
	StateStopping                    // Interrupt sent, waiting for process exit
	StateError                       // Unexpected process exit
)

func (ServerState) String added in v0.1.4

func (s ServerState) String() string

type Service

type Service struct {
	servicego.Defaults

	Context     context.Context
	CancelCause context.CancelCauseFunc
	// 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 {
	*slog.Logger `bind:"-"`
	Data         FactOpSettings `bind:"-"`
}

func (*Settings) Load added in v0.1.2

func (s *Settings) Load() error

func (*Settings) Save added in v0.1.2

func (s *Settings) Save() error

func (*Settings) Startup added in v0.1.0

func (s *Settings) Startup() error

type SoftMod

type SoftMod struct {
	slog.Logger
}

func (*SoftMod) Apply added in v0.1.0

func (sm *SoftMod) Apply(data []byte) error

type UDPBridge added in v0.1.0

type UDPBridge struct {
	slog.Logger
	Context  context.Context
	Nats     *Nats
	Settings *Settings
	// contains filtered or unexported fields
}

UDPBridge bridges factorio udp_send and udp_rec traffic to and from NATS

func (*UDPBridge) Shutdown added in v0.1.0

func (u *UDPBridge) Shutdown() error

func (*UDPBridge) Startup added in v0.1.0

func (u *UDPBridge) Startup() error

type WebServer

type WebServer struct {
	slog.Logger
	// contains filtered or unexported fields
}

func (*WebServer) ServeHTTP

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

func (*WebServer) Shutdown added in v0.1.0

func (w *WebServer) Shutdown() error

func (*WebServer) Startup added in v0.1.0

func (w *WebServer) Startup() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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