waggle-sensor / beehive-server

Waggle cloud software for aggregation, storage and analysis of sensor data from Waggle nodes.
14 stars 17 forks source link

An update needed on web-watchdog service #13

Closed gemblerz closed 8 years ago

gemblerz commented 8 years ago

When beehive-web service needs to be stopped or restarted, beehive-nginx service also has to be restarted to re-configure communication line between them.

In order to fix it, beehive-web-watchdog service needs to additionally check if external requests work. If not working, the service should restart nginx service as well. Below is the code snippet (See elif statement).

[Service]
Environment='CONTAINER=beehive-web'
Environment='NGINX_CONTAINER=beehive-nginx'
Environment='DATA=/mnt'

Restart=always
RestartSec=5

ExecStart=/bin/bash -c ' \
  while [ 1 ] ; do \
    sleep 2m ; \
    if [ $(curl --silent --max-time 10 $(docker inspect --format "{{ .NetworkSettings.Networks.beehive.IPAddress }}" beehive-web) | grep "This is the Waggle Beehive web server." | wc -l) -ne 1 ] ; then \
      docker rm -f ${CONTAINER} ; \
    elif [ $(curl --silent --max-time 10 beehive1.mcs.anl.gov | grep "This is the Waggle Beehive web server." | wc -l) -ne 1 ] ; then \
      docker rm -f ${NGINX_CONTAINER} ; \
    fi \
  done'
MuffinSpawn commented 8 years ago

Issue moved to waggle-sensor/development #29 via ZenHub