runtime

package
v0.0.0-...-e289d49 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 41 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 and a `server.cfg` is generated based on the contents of the Config fields.

func EnsureBinaries

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

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

func EnsurePlugins

func EnsurePlugins(
	ctx context.Context,
	gh *github.Client,
	cfg *run.Runtime,
	cacheDir string,
	noCache bool,
) (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(
	ctx context.Context,
	gh *github.Client,
	meta versioning.DependencyMeta,
	dir string,
	platform string,
	version string,
	cacheDir string,
	plugins bool,
	includes bool,
	noCache bool,
) (files []run.Plugin, err error)

EnsureVersionedPlugin automatically downloads a plugin binary from its github releases page

func EnsureVersionedPluginCached

func EnsureVersionedPluginCached(
	ctx context.Context,
	meta versioning.DependencyMeta,
	platform,
	version,
	cacheDir string,
	noCache bool,
	gh *github.Client,
) (
	filename string,
	resource *resource.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 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 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 GenerateServerCfg

func GenerateServerCfg(cfg *run.Runtime) (err error)

GenerateServerCfg creates a settings file in the SA:MP "server.cfg" format at the specified location nolint:gocyclo

func GetResource

func GetResource(resources []resource.Resource, platform string, version string) (*resource.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 InitialiseServer

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

InitialiseServer creates a samp.json by asking the user a series of questions nolint:gocyclo

func LoadEnvironmentVariables

func LoadEnvironmentVariables(cfg *run.Runtime)

LoadEnvironmentVariables loads Config fields from environment variables - the variable names are simply the `json` tag names uppercased and prefixed with `SAMP_` nolint:gocyclo

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 NewConfigFromEnvironment

func NewConfigFromEnvironment(dir string) (cfg run.Runtime, err error)

NewConfigFromEnvironment creates a Config from the given environment which includes a directory which is searched for either `samp.json` or `samp.yaml` and environment variable versions of the config parameters.

func PluginFromCache

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

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

func PluginFromNet

func PluginFromNet(
	ctx context.Context,
	gh *github.Client,
	meta versioning.DependencyMeta,
	platform string,
	version string,
	cacheDir string,
) (filename string, resource *resource.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,
	cacheDir string,
	passArgs,
	recover bool,
	output io.Writer,
	input io.Reader,
) (err 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,
	cacheDir string,
	passArgs bool,
	output io.Writer,
	input io.Reader,
) (err error)

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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