-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new env vars for web api and validate minute replication files (#354
) * Set env vars for web container * Update var names for rails - web container * Update liveness for minute replication job * Add env var for RAILS_ENV * Add env for RAILS_LOG_LEVEL * Add STORAGE env values for web
- Loading branch information
Showing
3 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,44 @@ | ||
#!/usr/bin/env bash | ||
# This is a script for the complex evaluation of whether Osmosis or other processes are running in the container. | ||
if [ $(ps -ef | grep -E 'java' | grep -v grep | wc -l) -ge 1 ]; then | ||
# Script to check if Osmosis (Java) is running and also check how old processed_files.log is. | ||
# If processed_files.log is older than MAX_AGE_MINUTES, then kill Osmosis. | ||
|
||
LOG_FILE="/mnt/data/processed_files.log" | ||
MAX_AGE_MINUTES=10 | ||
|
||
get_file_age_in_minutes() { | ||
local file="$1" | ||
if [ ! -f "$file" ]; then | ||
echo 999999 | ||
return | ||
fi | ||
local now | ||
local mtime | ||
now=$(date +%s) | ||
mtime=$(stat -c %Y "$file") | ||
local diff=$(( (now - mtime) / 60 )) | ||
echo "$diff" | ||
} | ||
|
||
# Check if Osmosis (Java) is running | ||
OSMOSIS_COUNT=$(ps -ef | grep -E 'java.*osmosis' | grep -v grep | wc -l) | ||
|
||
if [ "$OSMOSIS_COUNT" -ge 1 ]; then | ||
echo "Osmosis is running." | ||
exit 0 | ||
# Check how old the processed_files.log file is | ||
file_age=$(get_file_age_in_minutes "$LOG_FILE") | ||
echo "processed_files.log file age in minutes: $file_age" | ||
if [ "$file_age" -ge "$MAX_AGE_MINUTES" ]; then | ||
echo "processed_files.log is older than $MAX_AGE_MINUTES minutes. Attempting to kill Osmosis and restart the container..." | ||
# Kill the Osmosis process | ||
pkill -f "java.*osmosis" || true | ||
echo "Osmosis is not terminating. Force-killing the container..." | ||
echo "Container force-restart triggered." | ||
exit 2 | ||
else | ||
echo "processed_files.log is not too old. No action needed." | ||
exit 0 | ||
fi | ||
else | ||
echo "Osmosis is not running!" 1>&2 | ||
echo "Osmosis is not running!" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters