mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
util/systemd: explicitly check for os.ErrNotExist from sdnotify
Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
parent
2d5db90161
commit
719de8f0e1
@ -7,6 +7,7 @@
|
|||||||
package systemd
|
package systemd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
@ -36,14 +37,10 @@ func (l *logOnce) logf(format string, args ...interface{}) {
|
|||||||
|
|
||||||
func notifier() *sdnotify.Notifier {
|
func notifier() *sdnotify.Notifier {
|
||||||
getNotifyOnce.Do(func() {
|
getNotifyOnce.Do(func() {
|
||||||
sock := os.Getenv(sdnotify.Socket)
|
|
||||||
if sock == "" {
|
|
||||||
// Not running under systemd probably. Bail out before logging.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var err error
|
var err error
|
||||||
getNotifyOnce.v, err = sdnotify.Open(sock)
|
getNotifyOnce.v, err = sdnotify.New()
|
||||||
if err != nil {
|
// Not exist means probably not running under systemd, so don't log.
|
||||||
|
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||||
log.Printf("systemd: systemd-notifier error: %v", err)
|
log.Printf("systemd: systemd-notifier error: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user