Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

vendor: add github.com/okzk/sdnotify

Fabian Möller0bfa29cbcf09
diff --git a/Gopkg.lock b/Gopkg.lock
index 2588010c1..0e5059da1 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -150,6 +150,12 @@
packages = ["."]
revision = "4ed959e0540971545eddb8c75514973d670cf739"
+[[projects]]
+ branch = "master"
+ name = "github.com/okzk/sdnotify"
+ packages = ["."]
+ revision = "ed8ca104421a21947710335006107540e3ecb335"
+
[[projects]]
branch = "master"
name = "github.com/patrickmn/go-cache"
@@ -297,6 +303,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
- inputs-digest = "63cb991f1167ff9f656f36bf3bb59831cde5402d70729a5709088ae73388c69e"
+ inputs-digest = "f53d8d2a21862f225ba86e4575a68ce73db8957959ca507e5eded837c5dbcf73"
solver-name = "gps-cdcl"
solver-version = 1
diff --git a/Gopkg.toml b/Gopkg.toml
index a63c9cb43..fca515fd6 100644
--- a/Gopkg.toml
+++ b/Gopkg.toml
@@ -144,3 +144,7 @@
[[constraint]]
branch = "master"
name = "github.com/patrickmn/go-cache"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/okzk/sdnotify"
diff --git a/vendor/github.com/okzk/sdnotify/LICENSE b/vendor/github.com/okzk/sdnotify/LICENSE
new file mode 100644
index 000000000..46547518e
--- /dev/null
+++ b/vendor/github.com/okzk/sdnotify/LICENSE
@@ -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.
diff --git a/vendor/github.com/okzk/sdnotify/README.md b/vendor/github.com/okzk/sdnotify/README.md
new file mode 100644
index 000000000..ee85e0520
--- /dev/null
+++ b/vendor/github.com/okzk/sdnotify/README.md
@@ -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
\ No newline at end of file
diff --git a/vendor/github.com/okzk/sdnotify/notify.go b/vendor/github.com/okzk/sdnotify/notify.go
new file mode 100644
index 000000000..bd1ac59f8
--- /dev/null
+++ b/vendor/github.com/okzk/sdnotify/notify.go
@@ -0,0 +1,8 @@
+// +build !linux
+
+package sdnotify
+
+func SdNotify(state string) error {
+ // do nothing
+ return nil
+}
diff --git a/vendor/github.com/okzk/sdnotify/notify_linux.go b/vendor/github.com/okzk/sdnotify/notify_linux.go
new file mode 100644
index 000000000..0ca13a145
--- /dev/null
+++ b/vendor/github.com/okzk/sdnotify/notify_linux.go
@@ -0,0 +1,22 @@
+package sdnotify
+
+import (
+ "net"
+ "os"
+)
+
+func SdNotify(state string) error {
+ name := os.Getenv("NOTIFY_SOCKET")
+ if name == "" {
+ return SdNotifyNoSocket
+ }
+
+ 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
+}
diff --git a/vendor/github.com/okzk/sdnotify/sample/main.go b/vendor/github.com/okzk/sdnotify/sample/main.go
new file mode 100644
index 000000000..107a24d85
--- /dev/null
+++ b/vendor/github.com/okzk/sdnotify/sample/main.go
@@ -0,0 +1,47 @@
+package main
+
+import (
+ "github.com/okzk/sdnotify"
+ "log"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+)
+
+func reload() {
+ // Tells the service manager that the service is reloading its configuration.
+ sdnotify.SdNotifyReloading()
+
+ log.Println("reloading...")
+ time.Sleep(time.Second)
+ log.Println("reloaded.")
+
+ // The service must also send a "READY" notification when it completed reloading its configuration.
+ sdnotify.SdNotifyReady()
+}
+
+func main() {
+ log.Println("starting...")
+ time.Sleep(time.Second)
+ log.Println("started.")
+
+ // Tells the service manager that service startup is finished.
+ sdnotify.SdNotifyReady()
+
+ sigCh := make(chan os.Signal, 1)
+ signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
+ for sig := range sigCh {
+ if sig == syscall.SIGHUP {
+ reload()
+ } else {
+ break
+ }
+ }
+
+ // Tells the service manager that the service is beginning its shutdown.
+ sdnotify.SdNotifyStopping()
+
+ log.Println("existing...")
+ time.Sleep(time.Second)
+}
diff --git a/vendor/github.com/okzk/sdnotify/sample/sample.service b/vendor/github.com/okzk/sdnotify/sample/sample.service
new file mode 100644
index 000000000..75b403841
--- /dev/null
+++ b/vendor/github.com/okzk/sdnotify/sample/sample.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=sample
+
+[Service]
+Type=notify
+ExecStart=/path/to/sample
+ExecStop=/bin/kill -SIGTERM $MAINPID
+ExecReload=/bin/kill -SIGHUP $MAINPID
+
+[Install]
+WantedBy = multi-user.target
diff --git a/vendor/github.com/okzk/sdnotify/util.go b/vendor/github.com/okzk/sdnotify/util.go
new file mode 100644
index 000000000..78477b8d9
--- /dev/null
+++ b/vendor/github.com/okzk/sdnotify/util.go
@@ -0,0 +1,21 @@
+package sdnotify
+
+import "errors"
+
+var SdNotifyNoSocket = errors.New("No socket")
+
+func SdNotifyReady() error {
+ return SdNotify("READY=1")
+}
+
+func SdNotifyStopping() error {
+ return SdNotify("STOPPING=1")
+}
+
+func SdNotifyReloading() error {
+ return SdNotify("RELOADING=1")
+}
+
+func SdNotifyStatus(status string) error {
+ return SdNotify("STATUS=" + status)
+}