Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add liveness bash script #330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ FROM python:3.12-slim@sha256:740d94a19218c8dd584b92f804b1158f85b0d241e5215ea26ed
ADD . .
RUN python -m pip install --no-cache-dir .

COPY ./container/liveness.bash .

CMD run-detection
22 changes: 22 additions & 0 deletions container/liveness.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# Check for heartbeat file
CURRENT_TIME=$(date +%s)
FILE_TIME=$(date -r /tmp/heartbeat +%s)
DIFF=$((CURRENT_TIME - FILE_TIME))
if [ $DIFF -lt 20 ]; then
exit 0
else
exit 1
fi

# Test for a readable file the archive
FILE_LIST="/archive/NDXLOQ/Instrument/data/cycle_24_3/LOQ00110782.nxs /archive/NDXOSIRIS/Instrument/data/cycle_24_3/OSIRIS00149339.nxs /archive/NDXTOSCA/Instrument/data/cycle_24_3/TSC30650.nxs /archive/NDXMARI/Instrument/data/cycle_23_4/MAR29177.nxs"
for file in $FILE_LIST; do
if ! [ -r "$file" ]; then
exit 1
fi
done

# All checks previously passed
exit 0