From ab37995bd03a2732f2b1cfe21aadbcd773b7e580 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 30 Sep 2019 16:26:54 -0300 Subject: [PATCH] daemonize --- Dockerfile | 4 +--- monit.conf | 4 ++-- syncthing_start.sh | 13 +++++++++---- syncthing_stop.sh | 3 --- 4 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 syncthing_stop.sh diff --git a/Dockerfile b/Dockerfile index aa3e844..85fd11a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,8 @@ RUN tar x -Of syncthing-linux-amd64-v${VERSION}.tar.gz syncthing-linux-amd64-v${ RUN chmod +x /usr/local/bin/syncthing RUN strip --strip-all /usr/local/bin/syncthing -COPY ./syncthing_stop.sh /usr/local/bin/syncthing_stop COPY ./syncthing_start.sh /usr/local/bin/syncthing_start -RUN chmod 755 /usr/local/bin/syncthing_stop /usr/local/bin/syncthing_start +RUN chmod 755 /usr/local/bin/syncthing_start RUN echo /home/builder/packages/home > /etc/apk/repositories RUN apk add --no-cache daemonize @@ -19,7 +18,6 @@ RUN apk add --no-cache daemonize FROM sutty/monit:latest COPY --from=build /usr/local/bin/syncthing /usr/local/bin/syncthing -COPY --from=build /usr/local/bin/syncthing_stop /usr/local/bin/syncthing_stop COPY --from=build /usr/local/bin/syncthing_start /usr/local/bin/syncthing_start COPY --from=build /usr/sbin/daemonize /usr/sbin/daemonize COPY ./monit.conf /etc/monit.d/syncthing.conf diff --git a/monit.conf b/monit.conf index 993cdc9..9f58108 100644 --- a/monit.conf +++ b/monit.conf @@ -1,3 +1,3 @@ check process syncthing with pidfile /tmp/syncthing.pid - start program = "/usr/local/bin/syncthing_start" as uid "syncthing" - stop program = "/usr/local/bin/syncthing_stop" + start program = "/usr/local/bin/syncthing_start" + stop program = "/bin/sh -c 'cat /tmp/syncthing.pid | xargs kill'" diff --git a/syncthing_start.sh b/syncthing_start.sh index 461c61e..7236680 100644 --- a/syncthing_start.sh +++ b/syncthing_start.sh @@ -1,6 +1,11 @@ #!/bin/sh -daemonize -p /tmp/syncthing.pid -l /tmp/syncthing.pid \ -/usr/local/bin/syncthing -no-browser \ - -logfile="/home/syncthing/syncthing.log" \ - -gui-address="http://0.0.0.0:8443" +pid=/tmp/syncthing.pid +dir=/home/syncthing +log=/dev/log + +rm -f ${pid} + +daemonize -p ${pid} -l ${pid} -u syncthing -c ${dir} \ + -o ${log} -a -e ${log} \ + /usr/local/bin/syncthing -no-browser -gui-address='http://0.0.0.0:8443' diff --git a/syncthing_stop.sh b/syncthing_stop.sh deleted file mode 100644 index 0e59585..0000000 --- a/syncthing_stop.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -ps aux | grep syncthing | tr -s " " | cut -d " " -f 2 | xargs kill