daemoncmd

package
v3.0.0-rc69 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 36 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 New

func New(c *client.T) *T

func (*T) IsRunning

func (t *T) IsRunning() (bool, error)

IsRunning function detect daemon status using api

it returns true is daemon is running, else false

func (*T) LoadManager

func (t *T) LoadManager(ctx context.Context) error

func (*T) Restart

func (t *T) Restart(ctx context.Context, profile string) error

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) Run

func (t *T) Run(ctx context.Context, profile string) error

func (*T) SetAPIDaemonPid

func (t *T) SetAPIDaemonPid(pid int)

SetAPIDaemonPid says the command was forked by the daemon of pid, to serve a restart its api received.

func (*T) SetNode

func (t *T) SetNode(node string)

func (*T) Start

func (t *T) Start(ctx context.Context, profile string) error

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

func (t *T) Stop(ctx context.Context) error

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

func (t *T) StopWithoutManager() error

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

func (t *T) WaitRunning() error

WaitRunning function waits for daemon running

It needs to be called from a cli lock protection

Jump to

Keyboard shortcuts

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