Documentation
¶
Overview ¶
Package resapp provides bases for other app drivers
Index ¶
- Variables
- type BaseT
- type T
- func (t *T) BaseCmdArgs(ctx context.Context, s string, action string) ([]string, error)
- func (t *T) CmdArgs(ctx context.Context, s string, action string) ([]string, execCredential, error)
- func (t *T) CommonStatus(ctx context.Context) status.T
- func (t *T) CommonStop(ctx context.Context, r statuser) (err error)
- func (t *T) EncapEnv(ctx context.Context) ([]string, error)
- func (t *T) ExitCodeToStatus(exitCode int) (status.T, error)
- func (t *T) GetFuncOpts(ctx context.Context, s string, action string) ([]funcopt.O, error)
- func (t *T) GetTimeout(action string) time.Duration
- func (t *T) Info(ctx context.Context) (resource.InfoKeys, error)
- func (t *T) NetNSPath(ctx context.Context) (string, error)
- func (t *T) Provision(ctx context.Context) error
- func (t *T) Provisioned(ctx context.Context) (provisioned.T, error)
- func (t *T) Quiesce(ctx context.Context) (func(context.Context) error, error)
- func (t *T) SortKey() string
- func (t *T) Unprovision(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var ( BaseKeywordDesc = keywords.Keyword{ Attr: "Desc", Example: "rpc.idmapd", Option: "desc", Group: GroupIdentity.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/desc"), } BaseKeywordTimeout = keywords.Keyword{ Attr: "Timeout", Converter: converters.Duration, Example: "180", Option: "timeout", Group: GroupTimeouts.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/timeout"), } BaseKeywordStopTimeout = keywords.Keyword{ Attr: "StopTimeout", Converter: converters.Duration, Example: "180", Option: "stop_timeout", Group: GroupTimeouts.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/stop_timeout"), } BaseKeywordSecretsEnv = keywords.Keyword{ Attr: "SecretsEnv", Converter: converters.Shlex, Example: "CRT=cert1/server.pem sec1/*", Deprecated: "v3.0.0-rc57", ReplacedBy: "environment", Option: "secrets_environment", Group: GroupEnvironment.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/secrets_environment"), } BaseKeywordConfigsEnv = keywords.Keyword{ Attr: "ConfigsEnv", Converter: converters.Shlex, Example: "PORT=http/port webapp/app1* {name}/* {name}-debug/settings", Deprecated: "v3.0.0-rc57", ReplacedBy: "environment", Option: "configs_environment", Group: GroupEnvironment.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/configs_environment"), } BaseKeywordEnv = keywords.Keyword{ Attr: "Env", Example: "SLIP=slob OC3_DB_PASSWORD from ./sec/oc3 key db_password source random", Option: "environment", Group: GroupEnvironment.ID, Converter: converters.Shlex, Scopable: true, Text: keywords.NewText(fs, "text/kw/environment"), KeySources: datarecv.EnvironmentKeySources, } BaseKeywordRetCodes = keywords.Keyword{ Attr: "RetCodes", Default: "0:up 1:down", Example: "0:up 1:down 3:warn 4: n/a 5:undef", Option: "retcodes", Group: GroupStatus.ID, Required: false, Scopable: true, Text: keywords.NewText(fs, "text/kw/retcodes"), } BaseKeywordUmask = keywords.Keyword{ Attr: "Umask", Converter: converters.Umask, Example: "022", Option: "umask", Group: GroupProcess.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/umask"), } BaseKeywords = []*keywords.Keyword{ &BaseKeywordDesc, &BaseKeywordTimeout, &BaseKeywordStopTimeout, &BaseKeywordSecretsEnv, &BaseKeywordConfigsEnv, &BaseKeywordEnv, &BaseKeywordRetCodes, &BaseKeywordUmask, } )
var ( // GroupIdentity holds the label the resource is shown with. GroupIdentity = keywords.Group{ ID: "identity", Name: "Identity", Text: keywords.NewText(fs, "text/group/identity"), Order: 10, } // GroupProcess holds the commands the app runs, and the identity, // directory and network namespace they run with. GroupProcess = keywords.Group{ ID: "process", Name: "Process", Text: keywords.NewText(fs, "text/group/process"), Order: 30, } // GroupStatus holds how the check of the app makes the status of its // resource. It has the id, name and order of the status of the tasks. GroupStatus = keywords.Group{ ID: "status", Name: "Status", Text: keywords.NewText(fs, "text/group/status"), Order: 36, } // GroupEnvironment holds the variables the commands are given. GroupEnvironment = keywords.Group{ ID: "environment", Name: "Environment", Text: keywords.NewText(fs, "text/group/environment"), Order: 40, } // GroupLimits holds the limits om exec sets on a command of the node // before it runs it. GroupLimits = keywords.Group{ ID: "limits", Name: "Limits", Text: keywords.NewText(fs, "text/group/limits"), Order: 44, } // GroupQuiesce holds the commands suspending and resuming the writes // of the app for a run of a sync resource. It has the id, name and // order of the quiesce of the oci containers, with none of their // strategies: an app quiesces by a command alone. GroupQuiesce = keywords.Group{ ID: "quiesce", Name: "Quiesce", Text: keywords.NewText(fs, "text/group/quiesce"), Order: 75, } // GroupTimeouts holds how long the commands of the app may take. It // has the id, name and order of the timeouts of the containers and // tasks. GroupTimeouts = keywords.Group{ ID: "timeouts", Name: "Timeouts", Text: keywords.NewText(fs, "text/group/timeouts"), Order: 90, } // Groups are the groups the keywords of an app driver name. Groups = []keywords.Group{ GroupIdentity, GroupProcess, GroupStatus, GroupEnvironment, GroupLimits, GroupQuiesce, GroupTimeouts, } )
The groups of the keywords of the app drivers, app.forking and app.simple, declared once here and added by each app driver. They have the ids, names and orders of the groups of the containers and tasks holding the same topics, so a reader sees one vocabulary.
The host task borrows the keywords of the app drivers, which name these groups by their ids: it adds the environment and limits groups, and its own process group, its command running on the node or in a container.
The script running every command an app keyword sets to true is no strategy of the process group: a command set to true runs the script, a command set to a shell expression runs it, and an app mixes both.
var ( UnixKeywordScriptPath = keywords.Keyword{ Attr: "ScriptPath", Option: "script", Group: GroupProcess.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/script"), } UnixKeywordInfoCmd = keywords.Keyword{ Attr: "InfoCmd", Default: "false", Option: "info", Group: GroupProcess.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/info"), } UnixKeywordQuiesceCmd = keywords.Keyword{ Attr: "QuiesceCmd", Example: "/usr/local/bin/app-flush --lock", Option: "quiesce", Group: GroupQuiesce.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/quiesce"), } UnixKeywordResumeCmd = keywords.Keyword{ Attr: "ResumeCmd", Example: "/usr/local/bin/app-flush --unlock", Option: "resume", Group: GroupQuiesce.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/resume"), } UnixKeywordStatusLogKw = keywords.Keyword{ Attr: "StatusLogKw", Converter: converters.Bool, Default: "false", Option: "status_log", Group: GroupStatus.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/status_log"), } UnixKeywordCheckTimeout = keywords.Keyword{ Attr: "CheckTimeout", Converter: converters.Duration, Example: "180", Option: "check_timeout", Group: GroupTimeouts.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/check_timeout"), } UnixKeywordInfoTimeout = keywords.Keyword{ Attr: "InfoTimeout", Converter: converters.Duration, Example: "180", Option: "info_timeout", Group: GroupTimeouts.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/info_timeout"), } UnixKeywordCwd = keywords.Keyword{ Attr: "Cwd", Option: "cwd", Group: GroupProcess.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/cwd"), } UnixKeywordUser = keywords.Keyword{ Attr: "User", Option: "user", Group: GroupProcess.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/user"), } UnixKeywordGroup = keywords.Keyword{ Attr: "Group", Option: "group", Group: GroupProcess.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/group"), } UnixKeywordLimitCPU = keywords.Keyword{ Attr: "Limit.CPU", Converter: converters.Duration, Example: "30s", Option: "limit_cpu", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_cpu"), } UnixKeywordLimitCore = keywords.Keyword{ Attr: "Limit.Core", Converter: converters.Size, Option: "limit_core", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_core"), } UnixKeywordLimitData = keywords.Keyword{ Attr: "Limit.Data", Converter: converters.Size, Option: "limit_data", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_data"), } UnixKeywordLimitFSize = keywords.Keyword{ Attr: "Limit.FSize", Converter: converters.Size, Option: "limit_fsize", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_fsize"), } UnixKeywordLimitMemLock = keywords.Keyword{ Attr: "Limit.MemLock", Converter: converters.Size, Option: "limit_memlock", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_memlock"), } UnixKeywordLimitNoFile = keywords.Keyword{ Attr: "Limit.NoFile", Converter: converters.Size, Option: "limit_nofile", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_nofile"), } UnixKeywordLimitNProc = keywords.Keyword{ Attr: "Limit.NProc", Converter: converters.Size, Option: "limit_nproc", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_nproc"), } UnixKeywordLimitRSS = keywords.Keyword{ Attr: "Limit.RSS", Converter: converters.Size, Option: "limit_rss", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_rss"), } UnixKeywordLimitStack = keywords.Keyword{ Attr: "Limit.Stack", Converter: converters.Size, Option: "limit_stack", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_stack"), } UnixKeywordLimitVmem = keywords.Keyword{ Attr: "Limit.VMem", Converter: converters.Size, Option: "limit_vmem", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_vmem"), } UnixKeywordLimitAS = keywords.Keyword{ Attr: "Limit.AS", Converter: converters.Size, Option: "limit_as", Group: GroupLimits.ID, Scopable: true, Text: keywords.NewText(fs, "text/kw/limit_as"), } UnixKeywordNetNS = keywords.Keyword{ Attr: "NetNS", Example: "ip#0", Option: "netns", Group: GroupProcess.ID, References: &keywords.References{Groups: []string{"ip", "container", "app"}, Shape: keywords.ReferencesRID}, Scopable: true, Text: keywords.NewText(fs, "text/kw/netns"), } UnixKeywords = []*keywords.Keyword{ &UnixKeywordScriptPath, &UnixKeywordInfoCmd, &UnixKeywordQuiesceCmd, &UnixKeywordResumeCmd, &UnixKeywordStatusLogKw, &UnixKeywordCheckTimeout, &UnixKeywordInfoTimeout, &UnixKeywordCwd, &UnixKeywordUser, &UnixKeywordGroup, &UnixKeywordLimitCPU, &UnixKeywordLimitCore, &UnixKeywordLimitData, &UnixKeywordLimitFSize, &UnixKeywordLimitMemLock, &UnixKeywordLimitNoFile, &UnixKeywordLimitNProc, &UnixKeywordLimitRSS, &UnixKeywordLimitStack, &UnixKeywordLimitVmem, &UnixKeywordLimitAS, &UnixKeywordNetNS, } )
Functions ¶
This section is empty.
Types ¶
type BaseT ¶
type BaseT struct {
resource.T
resource.Restart
RetCodes string `json:"retcodes"`
Path naming.Path `json:"path"`
Nodes []string `json:"nodes"`
SecretsEnv []string `json:"secret_environment"`
ConfigsEnv []string `json:"configs_environment"`
Env []string `json:"environment"`
Timeout *time.Duration `json:"timeout"`
StartTimeout *time.Duration `json:"start_timeout"`
StopTimeout *time.Duration `json:"stop_timeout"`
Umask *os.FileMode `json:"umask"`
ObjectID uuid.UUID `json:"objectID"`
}
BaseT is the app base driver structure
type T ¶
type T struct {
BaseT
Path naming.Path `json:"path"`
Nodes []string `json:"nodes"`
ScriptPath string `json:"script"`
StartCmd string `json:"start"`
StopCmd string `json:"stop"`
CheckCmd string `json:"check"`
InfoCmd string `json:"info"`
QuiesceCmd string `json:"quiesce"`
ResumeCmd string `json:"resume"`
StatusLogKw bool `json:"status_log"`
CheckTimeout *time.Duration `json:"check_timeout"`
InfoTimeout *time.Duration `json:"info_timeout"`
Cwd string `json:"cwd"`
User string `json:"user"`
Group string `json:"group"`
PG pg.Config `json:"pg"`
Limit ulimit.Config `json:"limit"`
NetNS string `json:"netns"`
Desc string `json:"desc"`
}
T is the driver structure for app unix & linux.
func (*T) BaseCmdArgs ¶
func (*T) CmdArgs ¶
CmdArgs returns the command argv of an action, and the identity it is to run as.
func (*T) CommonStatus ¶
CommonStatus evaluates and display the Resource status and logs
func (*T) CommonStop ¶
CommonStop stops the Resource
func (*T) EncapEnv ¶
EncapEnv returns the environment of a command run in a container: the one of a command run on the node, but its PATH, which is the container's.
func (*T) GetFuncOpts ¶
GetFuncOpts returns a list of functional options to use with command.New()