view host/stop.sh @ 1724:32c6b085bb83

test custom nginx
author Vadim Filimonov <fffilimonov@yandex.ru>
date Thu, 11 Aug 2022 12:18:33 +0200
parents b735ed134662
children
line wrap: on
line source

#!/bin/bash

. check_app.sh;

#seconds to wait
toWait=30;
i=0;

getPids;

if [ "$PIDS" != "" ]; then
  while [ $i -lt $toWait ]; do
    kill -TERM $PIDS;
    sleep 1;
    getPids;
    if [ "$PIDS" == "" ]; then
      break
    fi;
    let i=$i+1;
  done;

  if [ "$PIDS" != "" ]; then
    echo "Can't stop app in ${i} seconds";
    exit 0;
  else
    rm started.lock;
    echo "App stopped";
  fi;
else
    echo "no running app found";
fi;

sudo $(which nginx) -s stop;
exit 0;