upstart

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package upstart interacts with the Upstart init daemon on behalf of local tests.

Package upstart interacts with the Upstart init daemon on behalf of local tests.

Index

Constants

View Source
const UIRestartTimeout = 60 * time.Second

UIRestartTimeout is the maximum amount of time that it takes to restart the ui upstart job. ui-post-stop can sometimes block for an extended period of time waiting for "cryptohome --action=pkcs11_terminate" to finish: https://crbug.com/860519

Variables

This section is empty.

Functions

func CheckJob

func CheckJob(ctx context.Context, job string, args ...Arg) error

CheckJob checks the named upstart job (and the specified instance) and returns an error if it isn't running or has a process in the zombie state. args is passed to the job as extra parameters, e.g. multiple-instance jobs can use it to specify an instance.

func DisableJob

func DisableJob(job string) error

DisableJob disables the given upstart job, which takes effect on the next reboot. The rootfs must be writable when this function is called.

func DumpJobs

func DumpJobs(ctx context.Context, path string) error

DumpJobs writes the snapshot of all jobs' status to path.

func EnableJob

func EnableJob(job string) error

EnableJob enables the given upstart job. The job must have already been disabled with DisableJob before this function is called. The rootfs must be writable when this function is called.

func EnsureJobRunning

func EnsureJobRunning(ctx context.Context, job string, args ...Arg) error

EnsureJobRunning starts job if it isn't currently running. If it is already running, this is a no-op. args is passed to the job as extra parameters, e.g. multiple-instance jobs can use it to specify an instance.

func IsJobEnabled

func IsJobEnabled(job string) (bool, error)

IsJobEnabled returns true if the given upstart job is enabled.

func JobExists

func JobExists(ctx context.Context, job string) bool

JobExists returns true if the supplied job exists (i.e. it has a config file known by Upstart).

func JobStatus

func JobStatus(ctx context.Context, job string, args ...Arg) (goal upstart.Goal, state upstart.State, pid int, err error)

JobStatus returns the current status of job. If the PID is unavailable (i.e. the process is not running), 0 will be returned. An error will be returned if the job is unknown (i.e. it has no config in /etc/init). args is passed to the job as extra parameters, e.g. multiple-instance jobs can use it to specify an instance.

func RestartJob

func RestartJob(ctx context.Context, job string, args ...Arg) error

RestartJob restarts the job (single-instance) or the specified instance of the job (multiple-instance). If the job (instance) is currently stopped, it will be started. Note that the job is reloaded if it is already running; this differs from the "initctl restart" behavior as described in Section 10.1.2, "restart", in the Upstart Cookbook. args is passed to the job as extra parameters, e.g. multiple-instance jobs can use it to specify an instance.

func RestartJobAndWaitForDbusService

func RestartJobAndWaitForDbusService(ctx context.Context, job, serviceName string) error

RestartJobAndWaitForDbusService is a utility for restarting jobs that provide named dbus services. It restarts the |job| as normal and waits for the |serviceName| service to be available.

func SetLogPriority

func SetLogPriority(ctx context.Context, p LogPriority) error

SetLogPriority sets the log priority of Upstart.

func StartJob

func StartJob(ctx context.Context, job string, args ...Arg) error

StartJob starts job. If it is already running, this returns an error. args is passed to the job as extra parameters, e.g. multiple-instance jobs can use it to specify an instance.

func StopJob

func StopJob(ctx context.Context, job string, args ...Arg) error

StopJob stops job or the specified job instance. If it is not currently running, this is a no-op. args is passed to the job as extra parameters, e.g. multiple-instance jobs can use it to specify an instance.

The ui job receives special behavior since it is restarted out-of-band by the ui-respawn job when session_manager exits. To work around this, when job is "ui", this function first waits for the job to reach a stable state. See https://crbug.com/891594.

func WaitForJobStatus

func WaitForJobStatus(ctx context.Context, job string, goal upstart.Goal, state upstart.State,
	gp GoalPolicy, timeout time.Duration, args ...Arg) error

WaitForJobStatus waits for job to have the status described by goal/state. gp controls the function's behavior if the job's goal doesn't match the requested one. If timeout is non-zero, it limits the amount of time to wait. args is passed to the job as extra parameters, e.g. multiple-instance jobs can use it to specify an instance.

Types

type Arg

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

Arg represents an extra argument passed to an upstart job.

func WithArg

func WithArg(key, value string) Arg

WithArg can be passed to job-related functions to specify an extra argument passed to a job.

type GoalPolicy

type GoalPolicy int

GoalPolicy describes how WaitForJobStatus should handle mismatched goals.

const (
	// TolerateWrongGoal indicates that it's acceptable for the job to initially
	// have a goal that doesn't match the requested one. WaitForJobStatus will
	// continue waiting for the requested goal.
	TolerateWrongGoal GoalPolicy = iota
	// RejectWrongGoal indicates that an error should be returned immediately
	// if the job doesn't have the requested goal.
	RejectWrongGoal
)

type LogPriority

type LogPriority int

LogPriority represents a logging priority of upstart. The system default is info. http://upstart.ubuntu.com/cookbook/#initctl-log-priority

const (
	// LogPriorityDebug is "debug" priority.
	LogPriorityDebug LogPriority = iota
	// LogPriorityInfo is "info" priority.
	LogPriorityInfo
	// LogPriorityMessage is "message" priority.
	LogPriorityMessage
	// LogPriorityWarn is "warn" priority.
	LogPriorityWarn
	// LogPriorityError is "error" priority.
	LogPriorityError
	// LogPriorityFatal is "fatal" priority.
	LogPriorityFatal
)

func (LogPriority) String

func (p LogPriority) String() string

Jump to

Keyboard shortcuts

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