runtime

package
v0.0.0-...-aef7015 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: GPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFileToRuntime

func CopyFileToRuntime(cacheDir, version, filePath string) (err error)

CopyFileToRuntime copies a specific file to execute to the specified version's runtime directory

func Ensure

func Ensure(ctx context.Context, gh *github.Client, cfg *run.Runtime, noCache bool) (err error)

Ensure will make sure a Config's dir is representative of the held configuration. If any of the following are missing or mismatching, they will be automatically downloaded: - Server binaries (server, announce, npc) - Plugin binaries - Scripts: gamemodes and filterscripts

func EnsurePlugins

func EnsurePlugins(request EnsurePluginsRequest) (err error)

EnsurePlugins validates and downloads plugin binary files.

func EnsureScripts

func EnsureScripts(cfg run.Runtime) (err error)

EnsureScripts checks that all the declared scripts are present

func EnsureVersionedPlugin

func EnsureVersionedPlugin(request EnsureVersionedPluginRequest) (files []run.Plugin, err error)

EnsureVersionedPlugin automatically downloads a plugin binary from its github releases page

func EnsureVersionedPluginCached

func EnsureVersionedPluginCached(request EnsureVersionedPluginCachedRequest) (
	filename string,
	resource *pkgresource.Resource,
	err error,
)

EnsureVersionedPluginCached ensures that a plugin exists in the cache

func FindPackage

func FindPackage(cacheDir, version string) (runtime download.RuntimePackage, err error)

FindPackage returns a server resource package for the given version or nil if it's invalid

func FindPackageContext

func FindPackageContext(ctx context.Context, cacheDir, version string) (runtime download.RuntimePackage, err error)

func FromCache

func FromCache(cacheDir, version, dir, platform string) (hit bool, err error)

FromCache tries to grab a server package from cache, `hit` indicates if it was successful

func FromCacheContext

func FromCacheContext(request ServerPackageRequest) (hit bool, err error)

func FromNet

func FromNet(cacheDir, version, dir, platform string) (err error)

FromNet downloads a server package to the cache, then calls FromCache to finish the job

func FromNetContext

func FromNetContext(request ServerPackageRequest) (err error)

FromNetContext downloads a server package to the cache, then extracts it to dir.

func GenerateConfig

func GenerateConfig(cfg *run.Runtime) error

GenerateConfig generates the runtime configuration file for cfg's effective runtime.

func GetResource

func GetResource(resources []pkgresource.Resource, platform string, version string) (*pkgresource.Resource, error)

GetResource searches a list of resources for one that matches the given platform

func GetResourcePath

func GetResourcePath(meta versioning.DependencyMeta) (path string)

GetResourcePath returns a path where a resource should be stored given the metadata

func GetRuntimePath

func GetRuntimePath(cacheDir, version string) (runtimeDir string)

GetRuntimePath returns the path from the cache directory where the runtime for a specific version of the server should exist.

func GetServerPackage

func GetServerPackage(version, dir, platform string) (err error)

GetServerPackage checks if a cached package is available and if not, downloads it to dir

func GetServerPackageContext

func GetServerPackageContext(ctx context.Context, version, dir, platform string) (err error)

GetServerPackageContext checks if a cached package is available and if not, downloads it to dir.

func MatchesChecksum

func MatchesChecksum(src, platform, cacheDir, version string) (ok bool, err error)

MatchesChecksum checks if the file at the given path src is the correct file for the specified runtime package via MD5 sum

func PluginFromCache

func PluginFromCache(
	meta versioning.DependencyMeta,
	platform string,
	version string,
	cacheDir string,
) (hit bool, filename string, resource *pkgresource.Resource, err error)

PluginFromCache tries to grab a plugin asset from the cache, `hit` indicates if it was successful

func PluginFromNet

func PluginFromNet(request PluginFetchRequest) (filename string, resource *pkgresource.Resource, err error)

PluginFromNet downloads a plugin from the given metadata to the cache directory

func PrepareRuntimeDirectory

func PrepareRuntimeDirectory(cacheDir, version, platform, scriptfiles string) (err error)

PrepareRuntimeDirectory sets up a directory in ~/.samp that contains the server runtime

func Run

func Run(ctx context.Context, cfg run.Runtime, options RunOptions) error

Run handles the actual running of the server process - it collects log output too.

func RunContainer

func RunContainer(
	ctx context.Context,
	cfg run.Runtime,
	options RunOptions,
) (err error)

RunContainer does what Run does but inside a Linux container nolint:gocyclo

Types

type EnsurePluginsRequest

type EnsurePluginsRequest struct {
	Context  context.Context
	GitHub   *github.Client
	Config   *run.Runtime
	CacheDir string
	NoCache  bool
}

EnsurePluginsRequest describes runtime plugin preparation.

type EnsureVersionedPluginCachedRequest

type EnsureVersionedPluginCachedRequest struct {
	Context  context.Context
	Meta     versioning.DependencyMeta
	Platform string
	Version  string
	CacheDir string
	NoCache  bool
	GitHub   *github.Client
}

EnsureVersionedPluginCachedRequest describes a cache lookup for a versioned plugin asset.

type EnsureVersionedPluginRequest

type EnsureVersionedPluginRequest struct {
	Context        context.Context
	GitHub         *github.Client
	Meta           versioning.DependencyMeta
	Dir            string
	Platform       string
	Version        string
	CacheDir       string
	PluginDestDir  string
	Plugins        bool
	Includes       bool
	NoCache        bool
	IgnorePatterns []string
}

EnsureVersionedPluginRequest describes plugin acquisition and extraction.

type PluginFetchRequest

type PluginFetchRequest struct {
	Context  context.Context
	GitHub   *github.Client
	Meta     versioning.DependencyMeta
	Platform string
	Version  string
	CacheDir string
}

PluginFetchRequest describes a plugin asset fetch from the network.

type RunOptions

type RunOptions struct {
	CacheDir string
	PassArgs bool
	Recover  bool
	Output   io.Writer
	Input    io.Reader
}

type RuntimeFileInfo

type RuntimeFileInfo struct {
	Path string
	Size int64
	Hash string
	Mode uint32
}

type RuntimeManifestInfo

type RuntimeManifestInfo struct {
	Version     string
	Platform    string
	RuntimeType string
	Files       []RuntimeFileInfo
}

func EnsureBinaries

func EnsureBinaries(cacheDir string, cfg run.Runtime) (*RuntimeManifestInfo, error)

EnsureBinaries ensures the dir has all the necessary files to run a server

func EnsureBinariesContext

func EnsureBinariesContext(ctx context.Context, cacheDir string, cfg run.Runtime) (*RuntimeManifestInfo, error)

EnsureBinariesContext ensures the dir has all the necessary files to run a server.

func GetRuntimeManifestInfo

func GetRuntimeManifestInfo(workingDir string) (*RuntimeManifestInfo, error)

type ServerPackageRequest

type ServerPackageRequest struct {
	Context  context.Context
	CacheDir string
	Version  string
	Dir      string
	Platform string
}

ServerPackageRequest describes a runtime package cache/download operation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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