Skip to content

Commit 9a9b26a

Browse files
committed
adding scripts to source to help deal with scheduled instances
1 parent dfc2fdf commit 9a9b26a

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

bin/remount_portal_source.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
# crontab should be entered as follows
5+
# @reboot /root/remout_portal_source.sh > /dev/null 2>&1
6+
MOUNT_DIR=$(ls -l /dev/disk/by-id/google-* | grep google-singlecell-data-disk | awk -F '/' '{ print $NF }')
7+
if [[ -n "$MOUNT_DIR" ]]; then
8+
echo "$(date): remounting google-singlecell-data-disk from /dev/$MOUNT_DIR" >> /home/jenkins/remount_log.txt
9+
mount -o discard,defaults /dev/$MOUNT_DIR /home/jenkins/deployments
10+
else
11+
echo -e "$(date): cannot remount google-singlecell-data-disk, available disks:\n$(ls -l /dev/disk/by-id/google-*)" >> /home/jenkins/remount_log.txt
12+
fi

bin/restart_portal_container.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
docker ps --filter "status=exited" | grep -e 'single_cell' | while read -r line ; do
7+
container_id=`echo $line | awk '{print $1}'`
8+
container_name=`echo $line | awk '{print $NF}'`
9+
echo "Restarting $container_name ($container_id) on $(date)" >> /home/jenkins/deployments/single_cell_portal_core/log/cron_out.log
10+
docker restart $container_id
11+
done

0 commit comments

Comments
 (0)