package
0.1.2
Repository: https://github.com/threefoldtech/zosbase.git
Documentation: pkg.go.dev

# README

zinit package

-zinit Package exposes function to interact with zinit service life cycle management. So we can add, remove, list ... services

Create zinit client

  • To interact with zinit services you first should create an instance on zinit client
cl := zinit.New("/var/run/zinit.sock")
// or just use default to connect to the default socket path
cl := zinit.Default()

Adding service

err := cl.AddService("name", zinit.InitService{
		Exec: cmd, // the command to be executed i.e the actual service
		Env: map[string]string{
			"Key": "value",
		},
        Oneshot: false,
		After:   []string{},
	})

Removing a service

 err := cl.RemoveService(name);

Loading a service so you can check its properties or do modifications

service, err := cl.LoadService(name)

list all services

services, err := cl.List()

Check if a specific service exists

exists, err := cl.Exists("name")

Getting a service by name

cfg, err := cl.Get("name")

Getting service status

status, err := cl.Status("name")

check if the service is exited/stopped

status, err := cl.Status("name")
exited := status.State.Exited()

Getting zinit binary version

version, err := cl.Version()

Rebooting and shutdown the node

err := cl.Reboot()
err := cl.Shutdown()

Starting/Stopping a service

err := cl.Start("name")
err := cl.stop("name")

Start/Stop a service and wait for it to start

err := cl.StartWait(time.Second*20, "name");
err := cl.StopWait(time.Second*20, "name");

Start monitoring a service

err := cl.Monitor("name");

Forget a stopped service

err := cl.Forget("name");

Kill a running service

err := cl.Kill("name", zinit.SIGTERM); // or choose whatever signal you want

Starting/Stopping multiple services

err := cl.StartMultiple(time.Second*20, "name1", "name2", ...., "namex")
err := cl.StopMultiple(time.Second*20, "name1", "name2", ...., "namex")

List services that matches some filters

filter1 := zinit.WithExec("udhcpc")
filter2 := zinit.zinit.WithName(dhcp)
matched, err := s.z.Matches(filter1, filter2)

Destroy a service (Destroy given services completely (stop, forget and remove))

err := cl.Destroy(20*time.Second, "name");

# Functions

AddService write the service into a file in the expected location for Zinit you usually want to call Monitor(name) after adding a service.
No description provided by the author
No description provided by the author
New create a new Zinit client.
RemoveService delete the service file from the filesystem make sure the service has been stopped and forgot before deleting it.
matches the exec basename.
matche the exec if it matches the given regular expression note that it has to be a valid regular expression, otherwise it won't be matched.
matches the service name.

# Constants

All the type of logging supported by zinit.
All the type of logging supported by zinit.
ServiceStateBlocked is returned if the service can't start because of an unsatisfied dependency.
ServiceStateError is return when we a service exit with an error (exit code != 0).
ServiceStateFailure is set of zinit can not spawn a service in the first placedue to a missing executable for example.
ServiceStateRunning is return when we a service process is running and healthy.
ServiceStateSpawned service has started, but zinit is not sure about its status yet.
ServiceStateSuccess is return when a one shot service exited without errors.
ServiceStateUnknown is return when we cannot determine the status of a service.
ServiceTargetDown means the service has been asked to stop.
ServiceTargetUp means the service has been asked to start.
All the type of logging supported by zinit.

# Variables

No description provided by the author
No description provided by the author
ErrUnknownService is an error that is returned when a service is unknown to zinit.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.
List of supported signal.

# Structs

Client is a client for zinit action it talks to zinit directly over its unis socket.
InitService represent a Zinit service file.
ServiceState describes the service state.
ServiceStatus represent the status of a service.

# Interfaces

No description provided by the author

# Type aliases

LogType is an enum type.
PossibleState represents the state of a service managed by zinit.
ServiceTarget represents the desired state of a service.
Signal is a type that maps linux signal to a string it is used by the Kill method.