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
- func CheckJob(ctx context.Context, job string, args ...Arg) error
- func DisableJob(job string) error
- func DumpJobs(ctx context.Context, path string) error
- func EnableJob(job string) error
- func EnsureJobRunning(ctx context.Context, job string, args ...Arg) error
- func IsJobEnabled(job string) (bool, error)
- func JobExists(ctx context.Context, job string) bool
- func JobStatus(ctx context.Context, job string, args ...Arg) (goal upstart.Goal, state upstart.State, pid int, err error)
- func RestartJob(ctx context.Context, job string, args ...Arg) error
- func RestartJobAndWaitForDbusService(ctx context.Context, job, serviceName string) error
- func SetLogPriority(ctx context.Context, p LogPriority) error
- func StartJob(ctx context.Context, job string, args ...Arg) error
- func StopJob(ctx context.Context, job string, args ...Arg) error
- func WaitForJobStatus(ctx context.Context, job string, goal upstart.Goal, state upstart.State, ...) error
- type Arg
- type GoalPolicy
- type LogPriority
Constants ¶
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 ¶
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 ¶
DisableJob disables the given upstart job, which takes effect on the next reboot. The rootfs must be writable when this function is called.
func EnableJob ¶
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 ¶
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 ¶
IsJobEnabled returns true if the given upstart job is enabled.
func JobExists ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
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