From 40814e477907e7ff82e971433ec236e62ef8972c Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Thu, 7 Apr 2016 14:07:35 +0100 Subject: [PATCH] put hupper config in config file Signed-off-by: Justin Cormack --- alpine/packages/hupper/etc/init.d/hupper | 10 ++++++---- alpine/packages/hupper/main.go | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/alpine/packages/hupper/etc/init.d/hupper b/alpine/packages/hupper/etc/init.d/hupper index 20ea5fd75..2a73e2205 100755 --- a/alpine/packages/hupper/etc/init.d/hupper +++ b/alpine/packages/hupper/etc/init.d/hupper @@ -15,24 +15,26 @@ start() ebegin "Starting docker config update manager" - [ -n "${PIDFILE}" ] || PIDFILE=/run/hupper.pid + PIDFILE=/run/hupper.pid + DOCKERPIDFILE=/run/docker.pid start-stop-daemon --start --quiet \ --background \ --exec /bin/hupper \ --make-pidfile --pidfile ${PIDFILE} \ - -- + -- -pidfile ${PIDFILE} -huppidfile ${DOCKERPIDFILE} \ + -path /Database/branch/master/watch/com.docker.driver.amd64-linux.node/etc.node/docker.node/daemon.json.node/tree.live eend $? "Failed to start hupper" } stop() { - [ -d /Databse ] || exit 0 + [ -d /Database ] || exit 0 ebegin "Stopping docker config update manager" - [ -n "${PIDFILE}" ] || PIDFILE=/run/hupper.pid + PIDFILE=/run/hupper.pid start-stop-daemon --stop --quiet --pidfile ${PIDFILE} diff --git a/alpine/packages/hupper/main.go b/alpine/packages/hupper/main.go index b131e0ab3..7005e6c37 100644 --- a/alpine/packages/hupper/main.go +++ b/alpine/packages/hupper/main.go @@ -18,18 +18,28 @@ var ( ) func init() { - flag.StringVar(&path, "path", "/Database/branch/master/watch/com.docker.driver.amd64-linux.node/etc.node/docker.node/daemon.json.node/tree.live", "path of the file to watch") - flag.StringVar(&huppidfile, "huppidfile", "/run/docker.pid", "pidfile for process to signal") - flag.StringVar(&pidfile, "pidfile", "/run/hupper.pid", "my pidfile") + flag.StringVar(&path, "path", "", "path of the file to watch") + flag.StringVar(&huppidfile, "huppidfile", "", "pidfile for process to signal") + flag.StringVar(&pidfile, "pidfile", "", "my pidfile") } func main() { log.SetFlags(0) flag.Parse() - pid := os.Getpid() - pidbytes := []byte(strconv.Itoa(pid)) - _ = ioutil.WriteFile(pidfile, pidbytes, 0644) + if path == "" { + log.Fatal("watch path not set") + } + + if huppidfile == "" { + log.Fatal("huppidfile not set") + } + + if pidfile != "" { + pid := os.Getpid() + pidbytes := []byte(strconv.Itoa(pid)) + _ = ioutil.WriteFile(pidfile, pidbytes, 0644) + } watch, err := os.Open(path) if err != nil {