instance

package
v4.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SingSubDir represents directory where Singularity instance files are stored
	SingSubDir = "sing"
	// LogSubDir represents directory where Singularity instance log files are stored
	LogSubDir = "logs"
)
View Source
const (
	// BasicLogFormat represents basic log format.
	BasicLogFormat = "basic"
	// KubernetesLogFormat represents kubernetes log format.
	KubernetesLogFormat = "kubernetes"
	// JSONLogFormat represents JSON log format.
	JSONLogFormat = "json"
)
View Source
const (
	// ProgPrefix is the prefix used by a singularity instance process
	ProgPrefix = "Singularity instance"
)

Variables

View Source
var LogFormats = map[string]LogFormatter{
	BasicLogFormat:      basicLogFormatter,
	KubernetesLogFormat: kubernetesLogFormatter,
	JSONLogFormat:       jsonLogFormatter,
}

LogFormats contains supported log format by default.

Functions

func CheckName

func CheckName(name string) error

CheckName checks if name is a valid instance name

func ExtractName

func ExtractName(name string) string

ExtractName extracts instance name from an instance:// URI

func GetDir

func GetDir(name string, subDir string) (string, error)

GetDir returns directory where instances file will be stored

func GetLogFilePaths

func GetLogFilePaths(name string, subDir string) (string, string, error)

GetLogFilePaths returns the paths of log files containing .err, .out streams, respectively

func ProcName

func ProcName(name string, username string) (string, error)

ProcName returns processus name based on instance name and username

func SetLogFile

func SetLogFile(name string, uid int, subDir string) (*os.File, *os.File, error)

SetLogFile replaces stdout/stderr streams and redirect content to log file

Types

type File

type File struct {
	Path       string `json:"-"`
	Pid        int    `json:"pid"`
	PPid       int    `json:"ppid"`
	Name       string `json:"name"`
	User       string `json:"user"`
	Image      string `json:"image"`
	Config     []byte `json:"config"`
	UserNs     bool   `json:"userns"`
	Cgroup     bool   `json:"cgroup"`
	IP         string `json:"ip"`
	LogErrPath string `json:"logErrPath"`
	LogOutPath string `json:"logOutPath"`
}

File represents an instance file storing instance information

func Add

func Add(name string, subDir string) (*File, error)

Add creates an instance file for a named instance in a privileged or unprivileged path

func Get

func Get(name string, subDir string) (*File, error)

Get returns the instance file corresponding to instance name

func List

func List(username string, name string, subDir string) ([]*File, error)

List returns instance files matching username and/or name pattern

func (*File) Delete

func (i *File) Delete() error

Delete deletes instance file

func (*File) Update

func (i *File) Update() error

Update stores instance information in associated instance file

type LogFormatter

type LogFormatter func(stream string, data string) string

LogFormatter implements a log formatter.

type Logger

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

Logger defines a file logger.

func NewLogger

func NewLogger(logPath string, formatter LogFormatter) (*Logger, error)

NewLogger instantiates a new logger with formatter and return it.

func (*Logger) Close

func (l *Logger) Close()

Close closes all pipe pairs created with NewWriter and also closes log file descriptor.

func (*Logger) NewWriter

func (l *Logger) NewWriter(stream string, dropCRNL bool) (*io.PipeWriter, error)

NewWriter create a new pipe pair for corresponding stream.

func (*Logger) ReOpenFile

func (l *Logger) ReOpenFile() error

ReOpenFile closes and re-open log file (eg: log rotation).

Jump to

Keyboard shortcuts

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