Skip to content

Commit

Permalink
debugging singularity local
Browse files Browse the repository at this point in the history
  • Loading branch information
cmatKhan committed Mar 12, 2024
1 parent 35e31fa commit 86b237e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ __pycache__/
*$py.class
.ipynb_checkpoints
*.ipynb
postgres_data/*
postgres_run/*
backup/*
postgres_log.txt
redis_log.txt
django_log.txt

# C extensions
*.so
Expand Down
23 changes: 14 additions & 9 deletions singularity_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ check_service_ready() {
start_service() {
case $1 in
postgres)
singularity exec --bind $yeastregulatorydb_local_postgres_data:/var/lib/postgresql/data \
--bind $yeastregulatorydb_local_postgres_data_backups:/backups \
singularity run --bind $postgres_data:/var/lib/postgresql/data \
--bind $postgres_run:/var/run/postgresql \
--bind $postgres_backup:/backups \
--env-file ./.envs/.local/.postgres $postgres_sif \
&>./postgres_log.txt &
check_service_ready "PostgreSQL" "pg_isready -h localhost -p 5432"
Expand All @@ -39,7 +40,7 @@ start_service() {
--env-file ./.envs/.local/.django \
--env-file ./.envs/.local/.postgres \
--env-file ./.envs/.local/.regulatory_data \
$django_sif /start &> django_log.txt &
$django_sif bash -c 'cd /app && /start' &> django_log.txt &
check_service_ready "Django app" "curl -s http://localhost:8000 > /dev/null"
;;
docs)
Expand Down Expand Up @@ -93,14 +94,16 @@ Launch Singularity containers for a Django application with optional services.
-r, --redis_sif PATH path to the Redis Singularity image file
-d, --django_sif PATH path to the Django Singularity image file
-o, --docs_sif PATH path to the Docs Singularity image file
-g, --postgres_data PATH path to the PostgreSQL data directory
-b, --postgres_backup PATH path to the PostgreSQL data backups directory
-g, --postgres_data PATH path to the PostgreSQL data directory, eg postgres_data
-b, --postgres_backup PATH path to the PostgreSQL data backups directory, eg postgres_backup
-v, --postgres_run PATH path to the PostgresSQL run directory, eg postgres_run
-t, --timeout MINUTES optional timeout in minutes for service readiness checks (default: 3)
-s, --services "SERVICE1 SERVICE2" optional comma separated, no spaces, list of services to start (e.g., postgres,redis,django)
Examples:
${0##*/} -p /path/to/postgres.sif -r /path/to/redis.sif -d /path/to/django.sif -o /path/to/docs.sif \\
-g /path/to/postgres_data -b /path/to/postgres_backup -t 3 -s "postgres redis django"
-g /path/to/postgres_data -b /path/to/postgres_backup -v postgres_run /path/to/postgres_run \\
-t 3 -s "postgres redis django"
EOF
}

Expand All @@ -109,13 +112,14 @@ postgres_sif=""
redis_sif=""
django_sif=""
docs_sif=""
postgres_data=""
postgres_backup=""
postgres_data=postgres_data
postgres_backup=postgres_backup
postgres_run=postgres_run
timeout_minutes=3
services_to_start=()

# Parse options
OPTS=$(getopt -o hp:r:d:o:g:b:t:s: --long help,postgres_sif:,redis_sif:,django_sif:,docs_sif:,postgres_data:,postgres_backup:,timeout:,services: -n 'parse-options' -- "$@")
OPTS=$(getopt -o hp:r:d:o:g:b:v:t:s: --long help,postgres_sif:,redis_sif:,django_sif:,docs_sif:,postgres_data:,postgres_backup:,postgres_run:,timeout:,services: -n 'parse-options' -- "$@")
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi

eval set -- "$OPTS"
Expand All @@ -129,6 +133,7 @@ while true; do
-o | --docs_sif ) docs_sif="$2"; shift 2 ;;
-g | --postgres_data ) postgres_data="$2"; shift 2 ;;
-b | --postgres_backup ) postgres_backup="$2"; shift 2 ;;
-v | --postgres_run ) postgres_run="$2"; shift 2 ;;
-t | --timeout ) timeout_minutes="$2"; shift 2 ;;
-s | --services )
IFS=',' read -r -a services_to_start <<< "$2"
Expand Down

0 comments on commit 86b237e

Please sign in to comment.