forked from External/ergo
parent
c53df2dc88
commit
6f24082705
10 changed files with 123 additions and 2 deletions
21
vendor/github.com/okzk/sdnotify/LICENSE
generated
vendored
Normal file
21
vendor/github.com/okzk/sdnotify/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 okzk
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
15
vendor/github.com/okzk/sdnotify/README.md
generated
vendored
Normal file
15
vendor/github.com/okzk/sdnotify/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# sdnotify
|
||||
|
||||
sd_notify utility for golang.
|
||||
|
||||
## Installation
|
||||
|
||||
go get github.com/okzk/sdnotify
|
||||
|
||||
## Example
|
||||
|
||||
see [sample/main.go](sample/main.go)
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
9
vendor/github.com/okzk/sdnotify/notify.go
generated
vendored
Normal file
9
vendor/github.com/okzk/sdnotify/notify.go
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// +build !linux
|
||||
|
||||
package sdnotify
|
||||
|
||||
// SdNotify sends a specified string to the systemd notification socket.
|
||||
func SdNotify(state string) error {
|
||||
// do nothing
|
||||
return nil
|
||||
}
|
||||
23
vendor/github.com/okzk/sdnotify/notify_linux.go
generated
vendored
Normal file
23
vendor/github.com/okzk/sdnotify/notify_linux.go
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package sdnotify
|
||||
|
||||
import (
|
||||
"net"
|
||||
"os"
|
||||
)
|
||||
|
||||
// SdNotify sends a specified string to the systemd notification socket.
|
||||
func SdNotify(state string) error {
|
||||
name := os.Getenv("NOTIFY_SOCKET")
|
||||
if name == "" {
|
||||
return ErrSdNotifyNoSocket
|
||||
}
|
||||
|
||||
conn, err := net.DialUnix("unixgram", nil, &net.UnixAddr{Name: name, Net: "unixgram"})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
_, err = conn.Write([]byte(state))
|
||||
return err
|
||||
}
|
||||
39
vendor/github.com/okzk/sdnotify/util.go
generated
vendored
Normal file
39
vendor/github.com/okzk/sdnotify/util.go
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package sdnotify
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ErrSdNotifyNoSocket is the error returned when the NOTIFY_SOCKET does not exist.
|
||||
var ErrSdNotifyNoSocket = errors.New("No socket")
|
||||
|
||||
// Ready sends READY=1 to the systemd notify socket.
|
||||
func Ready() error {
|
||||
return SdNotify("READY=1")
|
||||
}
|
||||
|
||||
// Stopping sends STOPPING=1 to the systemd notify socket.
|
||||
func Stopping() error {
|
||||
return SdNotify("STOPPING=1")
|
||||
}
|
||||
|
||||
// Reloading sends RELOADING=1 to the systemd notify socket.
|
||||
func Reloading() error {
|
||||
return SdNotify("RELOADING=1")
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return SdNotify("STATUS=" + status)
|
||||
}
|
||||
|
||||
// Watchdog sends WATCHDOG=1 to the systemd notify socket.
|
||||
func Watchdog() error {
|
||||
return SdNotify("WATCHDOG=1")
|
||||
}
|
||||
3
vendor/modules.txt
vendored
3
vendor/modules.txt
vendored
|
|
@ -35,6 +35,9 @@ github.com/go-sql-driver/mysql
|
|||
github.com/gorilla/websocket
|
||||
# github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef
|
||||
## explicit
|
||||
# github.com/okzk/sdnotify v0.0.0-20180710141335-d9becc38acbd
|
||||
## explicit
|
||||
github.com/okzk/sdnotify
|
||||
# github.com/onsi/ginkgo v1.12.0
|
||||
## explicit
|
||||
# github.com/onsi/gomega v1.9.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue