commit 19d9a38484f1fcd9a05909186531ce401dcc94bb
parent 4dbe86d40037375ca873d368da5ca0c080e40afd
Author: Louis Burda <quent.burda@gmail.com>
Date: Thu, 8 Jul 2021 12:37:30 +0200
replaced socat with ncat and small fixes
Diffstat:
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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