Documentation
¶
Index ¶
- Variables
- type Manager
- type T
- func (t *T) IsRunning() (bool, error)
- func (t *T) LoadManager(ctx context.Context) error
- func (t *T) Restart(ctx context.Context, profile string) error
- func (t *T) Run(ctx context.Context, profile string) error
- func (t *T) SetAPIDaemonPid(pid int)
- func (t *T) SetNode(node string)
- func (t *T) Start(ctx context.Context, profile string) error
- func (t *T) Stop(ctx context.Context) error
- func (t *T) StopWithoutManager() error
- func (t *T) WaitRunning() error
Constants ¶
This section is empty.
Variables ¶
var ( WaitRunningTimeout = 20 * time.Second WaitRunningDelay = 500 * time.Millisecond // WaitStoppedTimeout is how long a stop run outside of systemd waits // for the daemon to exit before it kills it. A daemon stops in a few // seconds, but in more than the 4 seconds this wait was on a loaded // node, which had it killed during a restart. A daemon not stopped in // a minute, the time the lifecycle commands wait for their lock, is // hung. Under systemd, the stop of the unit ExecStop has no limit of // its own: the TimeoutStopSec of the unit bounds it. WaitStoppedTimeout = time.Minute WaitStoppedDelay = 250 * time.Millisecond // WaitKilledTimeout is how long a stop waits for a daemon it killed // to be gone. WaitKilledTimeout = 5 * time.Second ErrAlreadyRunning = errors.New("daemon already running") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager interface {
// ActiveState returns the ActiveState of the unit: "active",
// "activating", "deactivating", "reloading", "inactive",
// "failed".
ActiveState(ctx context.Context) (string, error)
CalledFromManager() bool
Close() error
Defined(ctx context.Context) (bool, error)
// Start, Restart and Stop return when the job of the unit
// ended, and an error when its result is not "done".
Start(ctx context.Context) error
Restart(ctx context.Context) error
Stop(context.Context) error
// RestartDetached queues a restart of the unit, if it runs, from
// outside of the unit, and returns.
RestartDetached() error
IsSystemStopping() (bool, error)
}
Manager is the service manager running the daemon, systemd.
type T ¶
type T struct {
// contains filtered or unexported fields
}
func (*T) IsRunning ¶
IsRunning function detect daemon status using api
it returns true is daemon is running, else false
func (*T) Restart ¶
Restart restarts the daemon, and returns when it runs again.
Under systemd, the restart is a job of the unit, which a stop requested meanwhile replaces: the restart then fails, and the stop wins. A restart the api asked for, see SetAPIDaemonPid, is queued from outside of the unit, and returns at once.
Without systemd, the restart stops then starts the daemon, holding the cli lock: a stop requested meanwhile waits for the restart to end, then stops.
func (*T) SetAPIDaemonPid ¶
SetAPIDaemonPid says the command was forked by the daemon of pid, to serve a restart its api received.
func (*T) Start ¶
Start handle daemon start from command origin.
It is used to forward start control to (systemd) manager (when the origin is not systemd)
func (*T) Stop ¶
Stop stops the daemon.
Under systemd, the stop is a job of the unit, which replaces a start or a restart in progress: the stop wins. Called by the unit ExecStop, it asks the daemon to stop, and waits for it to exit, systemd escalating when it does not. Without systemd, it holds the cli lock, so a stop requested during a restart waits for it to end, then stops.
func (*T) StopWithoutManager ¶
StopWithoutManager stops the daemon run outside of systemd, holding the cli lock: a stop requested during a restart waits for its end, then stops.
func (*T) WaitRunning ¶
WaitRunning function waits for daemon running
It needs to be called from a cli lock protection