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 --- do.sh | 5 ++++- service/Dockerfile | 2 +- service/cleaner/main.c | 4 ++-- service/entrypoint.sh | 5 ++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/do.sh b/do.sh index 366d508..ef0ca01 100644 --- a/do.sh +++ b/do.sh @@ -84,9 +84,12 @@ elif [ "$1" == "ci-test" ]; then docker-compose -f service/docker-compose.yml down docker-compose -f checker/docker-compose.yml down -elif [ "$1" == "host-local" ]; then +elif [ "$1" == "host-socat" ]; then RESULTDIR=service/data/uploads socat -x -v -T180 -s TCP-LISTEN:9090,nodelay,reuseaddr,fork \ EXEC:./run-proxy.sh,raw,pty,echo=0,stderr +elif [ "$1" == "host-ncat" ]; then + RESULTDIR=service/data/uploads ncat -v -k -l -p 9090 \ + -m 200 --no-shutdown -w10s -i180s -c "./run-proxy.sh" elif [ "$1" == "parse-log" ]; then python3 -c ' #!/usr/bin/env python3 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