From 19d9a38484f1fcd9a05909186531ce401dcc94bb Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Thu, 8 Jul 2021 12:37:30 +0200 Subject: replaced socat with ncat and small fixes --- service/Dockerfile | 2 +- service/cleaner/main.c | 4 ++-- service/entrypoint.sh | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'service') diff --git a/service/Dockerfile b/service/Dockerfile index c49190e..af3b176 100644 --- a/service/Dockerfile +++ b/service/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:18.04 -RUN apt update && apt install -y --no-install-recommends socat gcc make libc6-dev libc6 libc-dev-bin +RUN apt update && apt install -y --no-install-recommends ncat gcc make libc6-dev libc6 libc-dev-bin RUN addgroup --system service RUN adduser --system --ingroup service --uid 1000 service diff --git a/service/cleaner/main.c b/service/cleaner/main.c index a9d8b6f..fce087f 100644 --- a/service/cleaner/main.c +++ b/service/cleaner/main.c @@ -101,6 +101,7 @@ main(int argc, const char **argv) if (!(f = fopen(oldpath, "r+"))) die("Missing index file: %s\n", oldpath); flock(fileno(f), LOCK_EX); + fflush(f); newpath = aprintf("%s/.index.next", dirpath); if (!(fn = fopen(newpath, "w+"))) @@ -137,8 +138,7 @@ main(int argc, const char **argv) fwrite(buf, 1, nread, f); ftruncate(fileno(f), ftell(f)); - nread = ftell(f); - + fflush(f); flock(fileno(f), LOCK_UN); fclose(f); fclose(fn); diff --git a/service/entrypoint.sh b/service/entrypoint.sh index ab00f61..d68257e 100755 --- a/service/entrypoint.sh +++ b/service/entrypoint.sh @@ -7,10 +7,9 @@ expiry=$((13*60)) while [ 1 ]; do reftime="$(($(date +%s)-$expiry))" echo "[FILE CLEANUP] @ $(date +%T)" - cleaner "$RESULTDIR" "$reftime" + cleaner "$RESULTDIR" "$reftime" &> /tmp/cleaner-log sleep 70 done & -CMD="socat -T180 -s TCP-LISTEN:9000,nodelay,reuseaddr,fork \ -EXEC:/service/build/stldoctor,raw,pty,echo=0,stderr" +CMD="ncat -k -l -p 9090 -m 200 --no-shutdown -w10s -i180s -e /service/build/stldoctor" su -s /bin/sh -c "$CMD" service -- cgit v1.2.3-71-gd317