Skip to content

Commit

Permalink
remove unused package; rework entrypoint script
Browse files Browse the repository at this point in the history
  • Loading branch information
marat2509 committed Dec 8, 2024
1 parent 718bd4b commit cecbef3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM alpine:latest
RUN apk update && apk upgrade && apk add --no-cache xterm git php php-curl php-fileinfo php-iconv php-mbstring php-openssl pcre php-simplexml php-sockets php-zlib php-json
RUN apk update && apk upgrade && apk add --no-cache git php php-curl php-fileinfo php-iconv php-mbstring php-openssl pcre php-simplexml php-sockets php-zlib php-json
WORKDIR /app
COPY core/ .
COPY entrypoint.sh .
Expand Down
21 changes: 14 additions & 7 deletions worker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@ if [ ! -f "/app/nod32ms.conf" ]; then
exit 1
fi


if [ -z "${UPDATE_INTERVAL}" ]; then
UPDATE_INTERVAL=3600
fi
UPDATE_INTERVAL=${UPDATE_INTERVAL:-3600}

while true; do
start_time=$(date +%s)
php /app/update.php
if [ ! $? -eq 0 ]; then
echo "E: Run script failed, exitting..."
end_time=$(date +%s)
duration=$((end_time - start_time))

if [ $? -ne 0 ]; then
echo "E: Run script failed after $duration s, exiting..."
exit 1
fi

sleep_time=$((UPDATE_INTERVAL - duration))

if [ "$sleep_time" -gt 0 ]; then
sleep "$sleep_time"
else
sleep $UPDATE_INTERVAL
echo "Warning: Script execution time ($duration s) exceeded UPDATE_INTERVAL ($UPDATE_INTERVAL s). Skipping sleep."
fi
done

0 comments on commit cecbef3

Please sign in to comment.