2017-11-19 23:03:27 +01:00
|
|
|
package sdnotify
|
|
|
|
|
2018-08-20 13:32:46 +02:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
)
|
2017-11-19 23:03:27 +01:00
|
|
|
|
2018-08-20 13:32:46 +02:00
|
|
|
// ErrSdNotifyNoSocket is the error returned when the NOTIFY_SOCKET does not exist.
|
|
|
|
var ErrSdNotifyNoSocket = errors.New("No socket")
|
2017-11-19 23:03:27 +01:00
|
|
|
|
2018-08-20 13:32:46 +02:00
|
|
|
// Ready sends READY=1 to the systemd notify socket.
|
|
|
|
func Ready() error {
|
2017-11-19 23:03:27 +01:00
|
|
|
return SdNotify("READY=1")
|
|
|
|
}
|
|
|
|
|
2018-08-20 13:32:46 +02:00
|
|
|
// Stopping sends STOPPING=1 to the systemd notify socket.
|
|
|
|
func Stopping() error {
|
2017-11-19 23:03:27 +01:00
|
|
|
return SdNotify("STOPPING=1")
|
|
|
|
}
|
|
|
|
|
2018-08-20 13:32:46 +02:00
|
|
|
// Reloading sends RELOADING=1 to the systemd notify socket.
|
|
|
|
func Reloading() error {
|
2017-11-19 23:03:27 +01:00
|
|
|
return SdNotify("RELOADING=1")
|
|
|
|
}
|
|
|
|
|
2018-08-20 13:32:46 +02:00
|
|
|
// Errno sends ERRNO=? to the systemd notify socket.
|
|
|
|
func Errno(errno int) error {
|
|
|
|
return SdNotify(fmt.Sprintf("ERRNO=%d", errno))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Status sends STATUS=? to the systemd notify socket.
|
|
|
|
func Status(status string) error {
|
2017-11-19 23:03:27 +01:00
|
|
|
return SdNotify("STATUS=" + status)
|
|
|
|
}
|
2018-08-20 13:32:46 +02:00
|
|
|
|
|
|
|
// Watchdog sends WATCHDOG=1 to the systemd notify socket.
|
|
|
|
func Watchdog() error {
|
|
|
|
return SdNotify("WATCHDOG=1")
|
|
|
|
}
|