Browse Source

Monitor Phusion Passenger and if it is not running restart it and send a

email to defined email address
master
Alex Buckley 2 years ago
parent
commit
3791e65858
  1. 2
      installmonit.sh
  2. 23
      koha-coce/README
  3. 37
      koha-coce/checkcoce.sh
  4. 6
      koha-coce/coce.conf
  5. 49
      koha-coce/restartcoce.sh

2
installmonit.sh

@ -7,8 +7,10 @@ bashpath=/usr/sbin/
cp ./koha-plack/plack.conf $monitpath/conf.d/plack.conf
cp ./koha-zebra/zebra.conf $monitpath/conf.d/zebra.conf
cp ./koha-coce/coce.conf $monitpath/conf.d/coce.conf
cp ./koha-zebra/*.sh $bashpath/
cp ./koha-plack/*.sh $bashpath/
cp ./koha-coce/*.sh $bashpath/
echo "What mailserver should we send through?"
read mailserver

23
koha-coce/README

@ -0,0 +1,23 @@
NAME
Koha::Contrib::koha-plack - Monit conf file and bash scripts to monitor and automatically restart failed Plack instances
VERSION
version 1
DESCRIPTION
MONITORING Plack
koha-plack directory contains a Monit .conf file (plack.conf) and two bash scripts (checkplack.sh and restartplack.sh). Move the plack.conf into the /etc/monit/conf.d directory and run monit using the following commands:
sudo su
sudo service monit start
monit start all
plack.conf will monitor your plack instances using the checkplack.sh script. If that script returns a 1 then the restartplack.sh script is run and that starts the appropriate plack instance
All output of the monitoring is logged in the /var/log/monit.log
AUTHOR
Catalyst IT 2017
This is free software, licensed under:
the GNU GPL version 3 or later.

37
koha-coce/checkcoce.sh

@ -0,0 +1,37 @@
#!/bin/bash
# This file is part of Koha.
#
# Copyright (C) 2019 Catalyst IT
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
set -e
# include helper functions
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
. "/usr/share/koha/bin/koha-functions.sh"
else
echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
exit 1;
fi
cocestatus=0
if !`sudo passenger-status`; then
cocestatus=0
else
cocestatus=1
fi
echo $cocestatus
exit $cocestatus

6
koha-coce/coce.conf

@ -0,0 +1,6 @@
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
check program checkcoce with path /usr/sbin/checkcoce.sh
if status = 1 then exec "/usr/sbin/restartcoce.sh"

49
koha-coce/restartcoce.sh

@ -0,0 +1,49 @@
#!/bin/bash
# This file is part of Koha.
#
# Copyright (C) 2017 Catalyst IT
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
set -e
. /lib/lsb/init-functions
# Read configuration variable file if it is present
[ -r /etc/default/koha-common ] && . /etc/default/koha-common
# include helper functions
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
. "/usr/share/koha/bin/koha-functions.sh"
else
echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
exit 1
fi
if !`sudo koha-passenger`; then
`cd /var/local/coce`
`sudo passenger start --port 8080 --daemonize`
else
`cd /var/local/coce`
`sudo passenger start --port 8080 --daemonize`
fi
if !`sudo koha-passenger`; then
warn "The passenger instance is now running"
else
warn "The passenger instance is not running"
fi
exit 0;
Loading…
Cancel
Save