Skip to content

Commit 691448b

Browse files
authored
Merge pull request #2216 from broadinstitute/jb-staging-deploy-schedule
Adding scripts for dealing with scheduled instance restart (SCP-5949)
2 parents 53a76d0 + 5777768 commit 691448b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

bin/remount_portal_source.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /usr/bin/env bash
2+
3+
# script to add to the root crontab to remount attached disk in correct location after scheduled instance restart,
4+
# which is used for staging and development VMs, but not production
5+
6+
# crontab should be entered as follows
7+
# @reboot /root/remout_portal_source.sh > /dev/null 2>&1
8+
9+
# More context: https://github.com/broadinstitute/single_cell_portal_core/pull/2216
10+
MOUNT_DIR=$(ls -l /dev/disk/by-id/google-* | grep google-singlecell-data-disk | awk -F '/' '{ print $NF }')
11+
if [[ -n "$MOUNT_DIR" ]]; then
12+
echo "$(date): remounting google-singlecell-data-disk from /dev/$MOUNT_DIR" >> /home/jenkins/remount_log.txt
13+
mount -o discard,defaults /dev/$MOUNT_DIR /home/jenkins/deployments
14+
else
15+
echo -e "$(date): cannot remount google-singlecell-data-disk, available disks:\n$(ls -l /dev/disk/by-id/google-*)" >> /home/jenkins/remount_log.txt
16+
fi

bin/restart_portal_container.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#! /usr/bin/env bash
2+
3+
# script to add to root crontab on a deployed host to check for crashed Docker containers and restart
4+
# crontab entry should be as follows:
5+
# */5 * * * * /root/restart_portal_container.sh > /dev/null 2>&1
6+
7+
# More context: https://github.com/broadinstitute/single_cell_portal_core/pull/2216
8+
docker ps --filter "status=exited" | grep -e 'single_cell' | while read -r line ; do
9+
container_id=`echo $line | awk '{print $1}'`
10+
container_name=`echo $line | awk '{print $NF}'`
11+
echo "Restarting $container_name ($container_id) on $(date)" >> /home/jenkins/deployments/single_cell_portal_core/log/cron_out.log
12+
docker restart $container_id
13+
done

0 commit comments

Comments
 (0)