Skip to content

Commit

Permalink
Merge pull request #322 from JaerongA/datajoint_pipeline
Browse files Browse the repository at this point in the history
feat: ✨ add a cronjob script for dj workers
  • Loading branch information
Thinh Nguyen authored Feb 2, 2024
2 parents 804c77f + bfd508c commit 2950627
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions docker/cron_script.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# This script will be run every 4 hours in a cron job.
# Open up a crontab ('crontab -e') and add the following:
# 0 */4 * * * /path/to/cron_script.bash
# For debugging, run ./cron_script.bash -v

verbose=0

while [[ "$#" -gt 0 ]]; do
case $1 in
-v|--verbose) verbose=1 ;;
esac
shift
done

# Verbose option for debugging
print_verbose() {
if [ "$verbose" -eq 1 ]; then
printf "[DEBUG] %s - %s\n\n" "$1" "$(date '+%Y-%m-%d %H:%M:%S')"
fi
}

print_verbose "Starting Ingestion..."
cd /nfs/nhome/live/aeon_db/aeon_mecha/docker/

if docker image inspect ghcr.io/sainsburywellcomecentre/aeon_mecha > /dev/null 2>&1; then
print_verbose "Removing existing aeon_mecha image..."
docker image rm ghcr.io/sainsburywellcomecentre/aeon_mecha
fi

print_verbose "Terminate worker containers..."
docker-compose down
if [ $? -eq 0 ]; then
print_verbose "Workers terminated successfully."
else
print_verbose "Failed to terminate workers."
fi

print_verbose "Restart containers..."
docker-compose up --detach
if [ $? -eq 0 ]; then
print_verbose "Containers restarted successfully."
else
print_verbose "Failed to restart containers."
fi

0 comments on commit 2950627

Please sign in to comment.