Documentation
¶
Index ¶
- Constants
- type T
- func (t *T) ActiveState(ctx context.Context) (string, error)
- func (t *T) CalledFromManager() bool
- func (t *T) Close() error
- func (t *T) Defined(ctx context.Context) (loaded bool, err error)
- func (t *T) IsSystemStopping() (bool, error)
- func (t *T) NotifyReady() (bool, error)
- func (t *T) NotifyStopping() (bool, error)
- func (t *T) NotifyWatchdog() (bool, error)
- func (t *T) Restart(ctx context.Context) error
- func (t *T) RestartDetached() error
- func (t *T) Start(ctx context.Context) error
- func (t *T) Stop(ctx context.Context) error
Constants ¶
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 ¶
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 ¶
ActiveState returns the ActiveState of the opensvc unit: "active", "activating", "deactivating", "reloading", "inactive" or "failed".
func (*T) CalledFromManager ¶
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) Defined ¶
Defined verify if opensvc systemd unit exists and returns true and job type when unit is loaded
func (*T) IsSystemStopping ¶
func (*T) NotifyReady ¶
NotifyReady sends NotifyReady to systemd
func (*T) NotifyStopping ¶
NotifyStopping sends NotifyStopping to systemd
func (*T) NotifyWatchdog ¶
NotifyWatchdog sends watch dog notify to systemd
func (*T) Restart ¶
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 ¶
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.