daemonsys

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 7 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

View Source
const (
	UnitName = "opensvc-server.service"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type T

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

T handle dbus.Conn for systemd

func New

func New(ctx context.Context) (*T, error)

New provides a connected object to dbus systemd that implement following interfaces:

ActiveState(ctx context.Context) (string, error)
CalledFromManager() bool
Close() error
NotifyWatchdog() (bool, error)
Restart(ctx context.Context) error
RestartDetached() error
Start(ctx context.Context) error
Stop(ctx context.Context) error

func (*T) ActiveState

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

ActiveState returns the ActiveState of the opensvc unit: "active", "activating", "deactivating", "reloading", "inactive" or "failed".

func (*T) CalledFromManager

func (t *T) CalledFromManager() bool

CalledFromManager detects if current process as been launched by systemd: it is the main process of the unit, the "om daemon run" of its ExecStart, or its control process, the "om daemon stop" of its ExecStop.

A process of the unit cgroup, or with its INVOCATION_ID, is not: every child of the daemon is there, as the "om cluster join" it forks, which, taken for systemd, stopped the daemon through the api and started another itself, out of the unit. The pids of the unit are said by systemd 219 too.

func (*T) Close

func (t *T) Close() error

Close closes systemd dbus connection

func (*T) Defined

func (t *T) Defined(ctx context.Context) (loaded bool, err error)

Defined verify if opensvc systemd unit exists and returns true and job type when unit is loaded

func (*T) IsSystemStopping

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

func (*T) NotifyReady

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

NotifyReady sends NotifyReady to systemd

func (*T) NotifyStopping

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

NotifyStopping sends NotifyStopping to systemd

func (*T) NotifyWatchdog

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

NotifyWatchdog sends watch dog notify to systemd

func (*T) Restart

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

Restart restarts the opensvc systemd unit, and returns when systemd ended the job: the daemon is ready, as the unit is of the notify type, or the job did not complete, as when a stop requested meanwhile replaced it.

The caller must not be a process of the unit: a restart does not wait for the processes of the unit cgroup other than the main one, and leaves them running, as the "om daemon restart" the api forks. RestartDetached is the one for those.

func (*T) RestartDetached

func (t *T) RestartDetached() error

RestartDetached asks systemd to restart the opensvc unit, through a systemctl run by systemd-run, and returns without waiting for it.

It is for the "om daemon restart" the api forks, which lives in the unit control group: run from there, systemd would find the command a left-over process of the unit while starting it again:

systemd[1]: Stopping OpenSVC server...
systemd[1]: opensvc-server.service: Succeeded.
systemd[1]: Stopped OpenSVC server.
systemd[1]: opensvc-server.service: Found left-over process 2899690 (om) in control group while starting unit. Ignoring.
systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
systemd[1]: opensvc-server.service: Found left-over process 2899697 (systemctl) in control group while starting unit. Ignoring.
systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
systemd[1]: Starting OpenSVC server...
systemd[1]: Started OpenSVC server.

It runs a try-restart, which restarts the unit only if it is active or activating: a stop requested between the api request and the queueing of the restart wins, where a restart would start the daemon again.

func (*T) Start

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

Start starts the opensvc systemd unit, and returns when systemd ended the job: an error when it is not done.

func (*T) Stop

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

Stop stops the opensvc systemd unit, and returns when systemd ended the job: an error when it is not done. The "replace" mode makes the stop replace a start or a restart queued or running: the stop wins.

Jump to

Keyboard shortcuts

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