server

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: MIT Imports: 42 Imported by: 11

Documentation

Index

Constants

View Source
const (
	DaemonMessageEvent   = "daemon message"
	InstallOutputEvent   = "install output"
	ConsoleOutputEvent   = "console output"
	StatusEvent          = "status"
	StatsEvent           = "stats"
	BackupCompletedEvent = "backup completed"
)

Defines all of the possible output events for a server. noinspection GoNameStartsWithPackageName

View Source
const (
	ProcessOfflineState  = "offline"
	ProcessStartingState = "starting"
	ProcessRunningState  = "running"
	ProcessStoppingState = "stopping"
)

Variables

View Source
var InvalidPathResolution = errors.New("invalid path resolution")

Error returned when there is a bad path provided to one of the FS calls.

Functions

func IsServerDoesNotExistError

func IsServerDoesNotExistError(err error) bool

func IsSuspendedError

func IsSuspendedError(err error) bool

func IsTooFrequentCrashError

func IsTooFrequentCrashError(err error) bool

func LoadDirectory

func LoadDirectory() error

Iterates over a given directory and loads all of the servers listed before returning them to the calling function.

func NewDockerEnvironment

func NewDockerEnvironment(server *Server) error

Creates a new base Docker environment. A server must still be attached to it.

Types

type Allocations

type Allocations struct {
	// Defines the default allocation that should be used for this server. This is
	// what will be used for {SERVER_IP} and {SERVER_PORT} when modifying configuration
	// files or the startup arguments for a server.
	DefaultMapping struct {
		Ip   string `json:"ip"`
		Port int    `json:"port"`
	} `json:"default" yaml:"default"`

	// Mappings contains all of the ports that should be assigned to a given server
	// attached to the IP they correspond to.
	Mappings map[string][]int `json:"mappings"`
}

Defines the allocations available for a given server. When using the Docker environment driver these correspond to mappings for the container that allow external connections.

type Archiver

type Archiver struct {
	Server *Server
}

Archiver represents a Server Archiver.

func (*Archiver) Archive

func (a *Archiver) Archive() error

Archive creates an archive of the server and deletes the previous one.

func (*Archiver) ArchiveName

func (a *Archiver) ArchiveName() string

ArchiveName returns the name of the server's archive.

func (*Archiver) ArchivePath

func (a *Archiver) ArchivePath() string

ArchivePath returns the path to the server's archive.

func (*Archiver) Checksum

func (a *Archiver) Checksum() (string, error)

Checksum computes a SHA256 checksum of the server's archive.

func (*Archiver) DeleteIfExists

func (a *Archiver) DeleteIfExists() error

DeleteIfExists deletes the archive if it exists.

func (*Archiver) Exists

func (a *Archiver) Exists() bool

Exists returns a boolean based off if the archive exists.

func (*Archiver) Stat

func (a *Archiver) Stat() (*Stat, error)

Stat stats the archive file.

type BuildSettings

type BuildSettings struct {
	// The total amount of memory in megabytes that this server is allowed to
	// use on the host system.
	MemoryLimit int64 `json:"memory_limit" yaml:"memory"`

	// The amount of additional swap space to be provided to a container instance.
	Swap int64 `json:"swap"`

	// The relative weight for IO operations in a container. This is relative to other
	// containers on the system and should be a value between 10 and 1000.
	IoWeight uint16 `json:"io_weight" yaml:"io"`

	// The percentage of CPU that this instance is allowed to consume relative to
	// the host. A value of 200% represents complete utilization of two cores. This
	// should be a value between 1 and THREAD_COUNT * 100.
	CpuLimit int64 `json:"cpu_limit" yaml:"cpu"`

	// The amount of disk space in megabytes that a server is allowed to use.
	DiskSpace int64 `json:"disk_space" yaml:"disk"`

	// Sets which CPU threads can be used by the docker instance.
	Threads string `json:"threads" yaml:"threads"`
}

The build settings for a given server that impact docker container creation and resource limits for a server instance.

func (*BuildSettings) ConvertedCpuLimit

func (b *BuildSettings) ConvertedCpuLimit() int64

Converts the CPU limit for a server build into a number that can be better understood by the Docker environment. If there is no limit set, return -1 which will indicate to Docker that it has unlimited CPU quota.

func (*BuildSettings) ConvertedSwap

func (b *BuildSettings) ConvertedSwap() int64

Returns the amount of swap available as a total in bytes. This is returned as the amount of memory available to the server initially, PLUS the amount of additional swap to include which is the format used by Docker.

type Collection

type Collection struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func GetServers

func GetServers() *Collection

func NewCollection

func NewCollection(servers []*Server) *Collection

Create a new collection from a slice of servers.

func (*Collection) Add

func (c *Collection) Add(s *Server)

Adds an item to the collection store.

func (*Collection) All

func (c *Collection) All() []*Server

Return all of the items in the collection.

func (*Collection) Filter

func (c *Collection) Filter(filter func(*Server) bool) []*Server

Returns only those items matching the filter criteria.

func (*Collection) Find

func (c *Collection) Find(filter func(*Server) bool) *Server

Returns a single element from the collection matching the filter. If nothing is found a nil result is returned.

func (*Collection) Remove

func (c *Collection) Remove(filter func(*Server) bool)

Removes all items from the collection that match the filter function.

type Console

type Console struct {
	Server      *Server
	HandlerFunc *func(string)
}

func (Console) Write

func (c Console) Write(b []byte) (int, error)

type CrashDetection

type CrashDetection struct {
	// If set to false, the system will not listen for crash detection events that
	// can indicate that the server stopped unexpectedly.
	Enabled bool `default:"true" json:"enabled" yaml:"enabled"`
	// contains filtered or unexported fields
}

type DockerEnvironment

type DockerEnvironment struct {
	Server *Server

	// The Docker client being used for this instance.
	Client *client.Client
	// contains filtered or unexported fields
}

Defines the base environment for Docker instances running through Wings.

func (*DockerEnvironment) Attach

func (d *DockerEnvironment) Attach() error

Attaches to the docker container itself and ensures that we can pipe data in and out of the process stream. This should not be used for reading console data as you *will* miss important output at the beginning because of the time delay with attaching to the output.

func (*DockerEnvironment) Create

func (d *DockerEnvironment) Create() error

Creates a new container for the server using all of the data that is currently available for it. If the container already exists it will be returned.

@todo pull the image being requested if it doesn't exist currently.

func (*DockerEnvironment) Destroy

func (d *DockerEnvironment) Destroy() error

Remove the Docker container from the machine. If the container is currently running it will be forcibly stopped by Docker.

func (*DockerEnvironment) DisableResourcePolling

func (d *DockerEnvironment) DisableResourcePolling() error

Closes the stats stream for a server process.

func (*DockerEnvironment) EnableResourcePolling

func (d *DockerEnvironment) EnableResourcePolling() error

Enables resource polling on the docker instance. Except we aren't actually polling Docker for this information, instead just sit there with an async process that lets Docker stream all of this data to us automatically.

func (*DockerEnvironment) Exists

func (d *DockerEnvironment) Exists() (bool, error)

Determines if the container exists in this environment.

func (*DockerEnvironment) ExitState

func (d *DockerEnvironment) ExitState() (uint32, bool, error)

Determine the container exit state and return the exit code and wether or not the container was killed by the OOM killer.

func (*DockerEnvironment) FollowConsoleOutput

func (d *DockerEnvironment) FollowConsoleOutput() error

Attaches to the log for the container. This avoids us missing cruicial output that happens in the split seconds before the code moves from 'Starting' to 'Attaching' on the process.

func (*DockerEnvironment) InSituUpdate

func (d *DockerEnvironment) InSituUpdate() error

Performs an in-place update of the Docker container's resource limits without actually making any changes to the operational state of the container. This allows memory, cpu, and IO limitations to be adjusted on the fly for individual instances.

func (*DockerEnvironment) IsRunning

func (d *DockerEnvironment) IsRunning() (bool, error)

Determines if the server's docker container is currently running. If there is no container present, an error will be raised (since this shouldn't be a case that ever happens under correctly developed circumstances).

You can confirm if the instance wasn't found by using client.IsErrNotFound from the Docker API.

@see docker/client/errors.go

func (*DockerEnvironment) OnBeforeStart

func (d *DockerEnvironment) OnBeforeStart() error

Run before the container starts and get the process configuration from the Panel. This is important since we use this to check configuration files as well as ensure we always have the latest version of an egg available for server processes.

This process will also confirm that the server environment exists and is in a bootable state. This ensures that unexpected container deletion while Wings is running does not result in the server becoming unbootable.

func (*DockerEnvironment) Readlog

func (d *DockerEnvironment) Readlog(len int64) ([]string, error)

Reads the log file for the server. This does not care if the server is running or not, it will simply try to read the last X bytes of the file and return them.

func (*DockerEnvironment) SendCommand

func (d *DockerEnvironment) SendCommand(c string) error

Sends the specified command to the stdin of the running container instance. There is no confirmation that this data is sent successfully, only that it gets pushed into the stdin.

func (*DockerEnvironment) Start

func (d *DockerEnvironment) Start() error

Starts the server environment and begins piping output to the event listeners for the console. If a container does not exist, or needs to be rebuilt that will happen in the call to OnBeforeStart().

func (*DockerEnvironment) Stop

func (d *DockerEnvironment) Stop() error

Stops the container that the server is running in. This will allow up to 10 seconds to pass before a failure occurs.

func (*DockerEnvironment) Terminate

func (d *DockerEnvironment) Terminate(signal os.Signal) error

Forcefully terminates the container using the signal passed through.

func (*DockerEnvironment) Type

func (d *DockerEnvironment) Type() string

Returns the name of the environment.

func (*DockerEnvironment) WaitForStop

func (d *DockerEnvironment) WaitForStop(seconds int, terminate bool) error

Attempts to gracefully stop a server using the defined stop command. If the server does not stop after seconds have passed, an error will be returned, or the instance will be terminated forcefully depending on the value of the second argument.

type Environment

type Environment interface {
	// Returns the name of the environment.
	Type() string

	// Determines if the environment is currently active and running a server process
	// for this specific server instance.
	IsRunning() (bool, error)

	// Performs an update of server resource limits without actually stopping the server
	// process. This only executes if the environment supports it, otherwise it is
	// a no-op.
	InSituUpdate() error

	// Runs before the environment is started. If an error is returned starting will
	// not occur, otherwise proceeds as normal.
	OnBeforeStart() error

	// Starts a server instance. If the server instance is not in a state where it
	// can be started an error should be returned.
	Start() error

	// Stops a server instance. If the server is already stopped an error should
	// not be returned.
	Stop() error

	// Waits for a server instance to stop gracefully. If the server is still detected
	// as running after seconds, an error will be returned, or the server will be terminated
	// depending on the value of the second argument.
	WaitForStop(seconds int, terminate bool) error

	// Determines if the server instance exists. For example, in a docker environment
	// this should confirm that the container is created and in a bootable state. In
	// a basic CLI environment this can probably just return true right away.
	Exists() (bool, error)

	// Terminates a running server instance using the provided signal. If the server
	// is not running no error should be returned.
	Terminate(signal os.Signal) error

	// Destroys the environment removing any containers that were created (in Docker
	// environments at least).
	Destroy() error

	// Returns the exit state of the process. The first result is the exit code, the second
	// determines if the process was killed by the system OOM killer.
	ExitState() (uint32, bool, error)

	// Creates the necessary environment for running the server process. For example,
	// in the Docker environment create will create a new container instance for the
	// server.
	Create() error

	// Attaches to the server console environment and allows piping the output to a
	// websocket or other internal tool to monitor output. Also allows you to later
	// send data into the environment's stdin.
	Attach() error

	// Follows the output from the server console and will begin piping the output to
	// the server's emitter.
	FollowConsoleOutput() error

	// Sends the provided command to the running server instance.
	SendCommand(string) error

	// Reads the log file for the process from the end backwards until the provided
	// number of bytes is met.
	Readlog(int64) ([]string, error)

	// Polls the given environment for resource usage of the server when the process
	// is running.
	EnableResourcePolling() error

	// Disables the polling operation for resource usage and sets the required values
	// to 0 in the server resource usage struct.
	DisableResourcePolling() error
}

Defines the basic interface that all environments need to implement so that a server can be properly controlled.

type Event

type Event struct {
	Data  string
	Topic string
}

type EventBus

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

func (*EventBus) Publish

func (e *EventBus) Publish(topic string, data string)

Publish data to a given topic.

func (*EventBus) PublishJson

func (e *EventBus) PublishJson(topic string, data interface{}) error

func (*EventBus) Subscribe

func (e *EventBus) Subscribe(topic string, ch chan Event)

Subscribe to an emitter topic using a channel.

func (*EventBus) Unsubscribe

func (e *EventBus) Unsubscribe(topic string, ch chan Event)

Unsubscribe a channel from a topic.

type FileWalker

type FileWalker struct {
	*Filesystem
}

func (*FileWalker) Walk

func (fw *FileWalker) Walk(dir string, ctx context.Context, callback func(os.FileInfo, string) bool) error

Iterate over all of the files and directories within a given directory. When a file is found the callback will be called with the file information. If a directory is encountered it will be recursively passed back through to this function.

type Filesystem

type Filesystem struct {
	// The server object associated with this Filesystem.
	Server *Server

	Configuration *config.SystemConfiguration
}

func (*Filesystem) Chown

func (fs *Filesystem) Chown(path string) error

Recursively iterates over a directory and sets the permissions on all of the underlying files.

func (*Filesystem) Copy

func (fs *Filesystem) Copy(p string) error

Copies a given file to the same location and appends a suffix to the file to indicate that it has been copied.

@todo need to get an exclusive lock on the file.

func (*Filesystem) CreateDirectory

func (fs *Filesystem) CreateDirectory(name string, p string) error

Creates a new directory (name) at a specificied path (p) for the server.

func (*Filesystem) Delete

func (fs *Filesystem) Delete(p string) error

Deletes a file or folder from the system. Prevents the user from accidentally (or maliciously) removing their root server data directory.

func (*Filesystem) DirectorySize

func (fs *Filesystem) DirectorySize(dir string) (int64, error)

Determines the directory size of a given location by running parallel tasks to iterate through all of the folders. Returns the size in bytes. This can be a fairly taxing operation on locations with tons of files, so it is recommended that you cache the output.

func (*Filesystem) EnsureDataDirectory

func (fs *Filesystem) EnsureDataDirectory() error

Ensures that the data directory for the server instance exists.

func (*Filesystem) GetIncludedFiles

func (fs *Filesystem) GetIncludedFiles(dir string, ignored []string) (*backup.IncludedFiles, error)

Given a directory, iterate through all of the files and folders within it and determine if they should be included in the output based on an array of ignored matches. This uses standard .gitignore formatting to make that determination.

If no ignored files are passed through you'll get the entire directory listing.

func (*Filesystem) HasSpaceAvailable

func (fs *Filesystem) HasSpaceAvailable() bool

Determines if the directory a file is trying to be added to has enough space available for the file to be written to.

Because determining the amount of space being used by a server is a taxing operation we will load it all up into a cache and pull from that as long as the key is not expired.

func (*Filesystem) ListDirectory

func (fs *Filesystem) ListDirectory(p string) ([]*Stat, error)

Lists the contents of a given directory and returns stat information about each file and folder within it.

func (*Filesystem) NewWalker

func (fs *Filesystem) NewWalker() *FileWalker

Returns a new walker instance.

func (*Filesystem) Path

func (fs *Filesystem) Path() string

Returns the root path that contains all of a server's data.

func (*Filesystem) Readfile

func (fs *Filesystem) Readfile(p string) (io.Reader, error)

Reads a file on the system and returns it as a byte representation in a file reader. This is not the most memory efficient usage since it will be reading the entirety of the file into memory.

func (*Filesystem) Rename

func (fs *Filesystem) Rename(from string, to string) error

Moves (or renames) a file or directory.

func (*Filesystem) SafePath

func (fs *Filesystem) SafePath(p string) (string, error)

Normalizes a directory being passed in to ensure the user is not able to escape from their data directory. After normalization if the directory is still within their home path it is returned. If they managed to "escape" an error will be returned.

This logic is actually copied over from the SFTP server code. Ideally that eventually either gets ported into this application, or is able to make use of this package.

func (*Filesystem) Stat

func (fs *Filesystem) Stat(p string) (*Stat, error)

Stats a file or folder and returns the base stat object from go along with the MIME data that can be used for editing files.

func (*Filesystem) Writefile

func (fs *Filesystem) Writefile(p string, r io.Reader) error

Writes a file to the system. If the file does not already exist one will be created.

@todo should probably have a write lock here so we don't write twice at once.

type InstallationProcess

type InstallationProcess struct {
	Server *Server
	Script *api.InstallationScript
	// contains filtered or unexported fields
}

func NewInstallationProcess

func NewInstallationProcess(s *Server, script *api.InstallationScript) (*InstallationProcess, error)

Generates a new installation process struct that will be used to create containers, and otherwise perform installation commands for a server.

func (*InstallationProcess) AfterExecute

func (ip *InstallationProcess) AfterExecute(containerId string) error

Cleans up after the execution of the installation process. This grabs the logs from the process to store in the server configuration directory, and then destroys the associated installation container.

func (*InstallationProcess) BeforeExecute

func (ip *InstallationProcess) BeforeExecute() (string, error)

Runs before the container is executed. This pulls down the required docker container image as well as writes the installation script to the disk. This process is executed in an async manner, if either one fails the error is returned.

func (*InstallationProcess) Execute

func (ip *InstallationProcess) Execute(installPath string) (string, error)

Executes the installation process inside a specially created docker container.

func (*InstallationProcess) GetLogPath

func (ip *InstallationProcess) GetLogPath() string

Returns the log path for the installation process.

func (*InstallationProcess) Run

func (ip *InstallationProcess) Run() error

Runs the installation process, this is done as a backgrounded thread. This will configure the required environment, and then spin up the installation container.

Once the container finishes installing the results will be stored in an installation log in the server's configuration directory.

func (*InstallationProcess) StreamOutput

func (ip *InstallationProcess) StreamOutput(id string) error

Streams the output of the installation process to a log file in the server configuration directory, as well as to a websocket listener so that the process can be viewed in the panel by administrators.

type PowerAction

type PowerAction struct {
	Action string `json:"action"`
}

func (*PowerAction) IsValid

func (pr *PowerAction) IsValid() bool

type ResourceUsage

type ResourceUsage struct {
	// The total amount of memory, in bytes, that this server instance is consuming.
	Memory uint64 `json:"memory_bytes"`
	// The total amount of memory this container or resource can use. Inside Docker this is
	// going to be higher than you'd expect because we're automatically allocating overhead
	// abilities for the container, so its not going to be a perfect match.
	MemoryLimit uint64 `json:"memory_limit_bytes"`
	// The absolute CPU usage is the amount of CPU used in relation to the entire system and
	// does not take into account any limits on the server process itself.
	CpuAbsolute float64 `json:"cpu_absolute"`
	// The current disk space being used by the server. This is cached to prevent slow lookup
	// issues on frequent refreshes.
	Disk int64 `json:"disk_bytes"`
	// Current network transmit in & out for a container.
	Network struct {
		RxBytes uint64 `json:"rx_bytes"`
		TxBytes uint64 `json:"tx_bytes"`
	} `json:"network"`
}

Defines the current resource usage for a given server instance. If a server is offline you should obviously expect memory and CPU usage to be 0. However, disk will always be returned since that is not dependent on the server being running to collect that data.

func (*ResourceUsage) CalculateAbsoluteCpu

func (ru *ResourceUsage) CalculateAbsoluteCpu(pStats *types.CPUStats, stats *types.CPUStats) float64

Calculates the absolute CPU usage used by the server process on the system, not constrained by the defined CPU limits on the container.

@see https://github.com/docker/cli/blob/aa097cf1aa19099da70930460250797c8920b709/cli/command/container/stats_helpers.go#L166

type Server

type Server struct {
	// The unique identifier for the server that should be used when referencing
	// it against the Panel API (and internally). This will be used when naming
	// docker containers as well as in log output.
	Uuid string `json:"uuid"`

	// Whether or not the server is in a suspended state. Suspended servers cannot
	// be started or modified except in certain scenarios by an admin user.
	Suspended bool `json:"suspended"`

	// The power state of the server.
	State string `default:"offline" json:"state"`

	// The command that should be used when booting up the server instance.
	Invocation string `json:"invocation"`

	// An array of environment variables that should be passed along to the running
	// server process.
	EnvVars map[string]string `json:"environment" yaml:"environment"`

	Archiver       Archiver       `json:"-" yaml:"-"`
	CrashDetection CrashDetection `json:"crash_detection" yaml:"crash_detection"`
	Build          BuildSettings  `json:"build"`
	Allocations    Allocations    `json:"allocations"`
	Environment    Environment    `json:"-" yaml:"-"`
	Filesystem     Filesystem     `json:"-" yaml:"-"`
	Resources      ResourceUsage  `json:"resources" yaml:"-"`

	Container struct {
		// Defines the Docker image that will be used for this server
		Image string `json:"image,omitempty"`
		// If set to true, OOM killer will be disabled on the server's Docker container.
		// If not present (nil) we will default to disabling it.
		OomDisabled bool `default:"true" json:"oom_disabled" yaml:"oom_disabled"`
	} `json:"container,omitempty"`

	// Server cache used to store frequently requested information in memory and make
	// certain long operations return faster. For example, FS disk space usage.
	Cache *cache.Cache `json:"-" yaml:"-"`

	// Internal mutex used to block actions that need to occur sequentially, such as
	// writing the configuration to the disk.
	sync.RWMutex
	// contains filtered or unexported fields
}

High level definition for a server instance being controlled by Wings.

func FromConfiguration

func FromConfiguration(data *api.ServerConfigurationResponse) (*Server, error)

Initializes a server using a data byte array. This will be marshaled into the given struct using a YAML marshaler. This will also configure the given environment for a server.

func (*Server) AddEventListeners

func (s *Server) AddEventListeners()

Adds all of the internal event listeners we want to use for a server.

func (*Server) BackupLocal

func (s *Server) BackupLocal(b *backup.LocalBackup) error

Performs a server backup and then emits the event over the server websocket. We let the actual backup system handle notifying the panel of the status, but that won't emit a websocket event.

func (*Server) CreateEnvironment

func (s *Server) CreateEnvironment() error

Initalizes a server instance. This will run through and ensure that the environment for the server is setup, and that all of the necessary files are created.

func (*Server) Events

func (s *Server) Events() *EventBus

Returns the server's emitter instance.

func (*Server) GetEnvironmentVariables

func (s *Server) GetEnvironmentVariables() []string

Returns all of the environment variables that should be assigned to a running server instance.

func (*Server) GetProcessConfiguration

func (s *Server) GetProcessConfiguration() (*api.ServerConfigurationResponse, *api.RequestError, error)

Gets the process configuration data for the server.

func (*Server) GetState

func (s *Server) GetState() string

Returns the current state of the server in a race-safe manner.

func (*Server) HandlePowerAction

func (s *Server) HandlePowerAction(action PowerAction) error

Helper function that can receieve a power action and then process the actions that need to occur for it.

func (*Server) Install

func (s *Server) Install() error

Executes the installation stack for a server process. Bubbles any errors up to the calling function which should handle contacting the panel to notify it of the server state.

func (*Server) IsBootable

func (s *Server) IsBootable() bool

Determine if the server is bootable in it's current state or not. This will not indicate why a server is not bootable, only if it is.

func (*Server) IsRunning

func (s *Server) IsRunning() bool

Determines if the server state is running or not. This is different than the environment state, it is simply the tracked state from this daemon instance, and not the response from Docker.

func (*Server) PublishConsoleOutputFromDaemon

func (s *Server) PublishConsoleOutputFromDaemon(data string)

Sends output to the server console formatted to appear correctly as being sent from Wings.

func (*Server) ReadLogfile

func (s *Server) ReadLogfile(len int64) ([]string, error)

Reads the log file for a server up to a specified number of bytes.

func (*Server) Reinstall

func (s *Server) Reinstall() error

Reinstalls a server's software by utilizing the install script for the server egg. This does not touch any existing files for the server, other than what the script modifies.

func (*Server) SetState

func (s *Server) SetState(state string) error

Sets the state of the server internally. This function handles crash detection as well as reporting to event listeners for the server.

func (*Server) Sync

func (s *Server) Sync() error

Syncs the state of the server on the Panel with Wings. This ensures that we're always using the state of the server from the Panel and allows us to not require successful API calls to Wings to do things.

This also means mass actions can be performed against servers on the Panel and they will automatically sync with Wings when the server is started.

func (*Server) SyncInstallState

func (s *Server) SyncInstallState(successful bool) error

Makes a HTTP request to the Panel instance notifying it that the server has completed the installation process, and what the state of the server is. A boolean value of "true" means everything was successful, "false" means something went wrong and the server must be deleted and re-created.

func (*Server) SyncWithConfiguration

func (s *Server) SyncWithConfiguration(cfg *api.ServerConfigurationResponse) error

func (*Server) UpdateConfigurationFiles

func (s *Server) UpdateConfigurationFiles()

Parent function that will update all of the defined configuration files for a server automatically to ensure that they always use the specified values.

func (*Server) UpdateDataStructure

func (s *Server) UpdateDataStructure(data []byte, background bool) error

Merges data passed through in JSON form into the existing server object. Any changes to the build settings will apply immediately in the environment if the environment supports it.

The server will be marked as requiring a rebuild on the next boot sequence, it is up to the specific environment to determine what needs to happen when that is the case.

type Stat

type Stat struct {
	Info     os.FileInfo
	Mimetype string
}

Defines the stat struct object.

func (*Stat) CTime

func (s *Stat) CTime() time.Time

Returns the time that the file/folder was created.

func (*Stat) MarshalJSON

func (s *Stat) MarshalJSON() ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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