aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-os-chef/scripts/docker_watchdog.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sdc-os-chef/scripts/docker_watchdog.sh')
-rw-r--r--sdc-os-chef/scripts/docker_watchdog.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/sdc-os-chef/scripts/docker_watchdog.sh b/sdc-os-chef/scripts/docker_watchdog.sh
new file mode 100644
index 0000000000..cc8452537b
--- /dev/null
+++ b/sdc-os-chef/scripts/docker_watchdog.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+if [ $# -eq 0 ]; then
+ echo "No arguments supplied"
+ exit 1
+fi
+
+
+RELEASE=$1
+DEP_ENV=$2
+
+
+docker_ids=`docker ps -a | egrep "Exit" | awk '{print $1}'`
+for X in ${docker_ids}
+do
+ docker rm -f ${X}
+done
+
+export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
+
+echo ""
+
+# Back-End
+my_cnt=`docker ps|egrep -c "sdc-backend:${RELEASE}"`
+if [ "${my_cnt}" -eq "1" ]; then
+# echo "`date` - BE is running" >> /data/ASDC/logs/watchdog.log
+ echo "`date` - BE is running" > /dev/null
+else
+ echo "`date` - BE was down" >> /data/ASDC/logs/watchdog.log
+ docker pull ecomp-nexus:51212/ecomp/sdc-backend:${RELEASE}
+ docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 3g --memory-swap=3g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/ASDC/logs/BE/:/var/lib/jetty/logs --volume /data/ASDC/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ecomp-nexus:51212/ecomp/sdc-backend:${RELEASE}
+fi
+
+# Front-End
+my_cnt=`docker ps|egrep -c "sdc-frontend:${RELEASE}"`
+if [ "${my_cnt}" -eq "1" ]; then
+# echo "`date` - FE is running" >> /data/ASDC/logs/watchdog.log
+ echo "`date` - FE is running" >> /dev/null
+else
+ echo "`date` - FE was down" >> /data/ASDC/logs/watchdog.log
+ docker pull ecomp-nexus:51212/ecomp/sdc-frontend:${RELEASE}
+ docker run --detach --name sdc-FE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 2g --memory-swap=2g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/ASDC/logs/FE/:/var/lib/jetty/logs --volume /data/ASDC/environments:/root/chef-solo/environments --publish 9443:9443 --publish 8181:8181 ecomp-nexus:51212/ecomp/sdc-frontend:${RELEASE}
+fi