From 7b81c079f6162a9ccb998b8a1ce38b6e24a16a6e Mon Sep 17 00:00:00 2001 From: Bart Van Der Meerssche Date: Sun, 17 Apr 2011 22:08:56 +0200 Subject: [PATCH] [fluksod] add a crontab entry that checks up on the daemon every 15min --- mote/v2/openwrt/package/flukso/Makefile | 4 ++++ .../openwrt/package/flukso/config/fcheck.sh | 24 +++++++++++++++++++ .../openwrt/package/flukso/config/flukso.init | 12 ++++++++++ 3 files changed, 40 insertions(+) create mode 100755 mote/v2/openwrt/package/flukso/config/fcheck.sh diff --git a/mote/v2/openwrt/package/flukso/Makefile b/mote/v2/openwrt/package/flukso/Makefile index 9ea9407..0edf328 100644 --- a/mote/v2/openwrt/package/flukso/Makefile +++ b/mote/v2/openwrt/package/flukso/Makefile @@ -51,15 +51,19 @@ define Package/flukso/install $(INSTALL_DATA) $(PKG_BUILD_DIR)/rrd/*.lua $(1)/usr/lib/lua/rrd/ $(INSTALL_DIR) $(1)/usr/lib/lua/flukso $(INSTALL_DATA) $(PKG_BUILD_DIR)/flukso/*.lua $(1)/usr/lib/lua/flukso/ + $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/luad $(1)/usr/sbin/ $(LN) /usr/sbin/luad $(1)/usr/sbin/fluksod $(INSTALL_BIN) $(PKG_BUILD_DIR)/fluksod.lua $(1)/usr/sbin/ $(LN) /usr/sbin/luad $(1)/usr/sbin/spid $(INSTALL_BIN) $(PKG_BUILD_DIR)/spid.lua $(1)/usr/sbin/ + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/heartbeat.lua $(1)/usr/bin/heartbeat $(INSTALL_BIN) $(PKG_BUILD_DIR)/fsync.lua $(1)/usr/bin/fsync $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdude.lua $(1)/usr/bin/fdude + $(INSTALL_BIN) $(PKG_BUILD_DIR)/fcheck.sh $(1)/usr/bin/fcheck $(INSTALL_BIN) $(PKG_BUILD_DIR)/restful.lua $(1)/usr/bin/restful endef diff --git a/mote/v2/openwrt/package/flukso/config/fcheck.sh b/mote/v2/openwrt/package/flukso/config/fcheck.sh new file mode 100755 index 0000000..6aaceb7 --- /dev/null +++ b/mote/v2/openwrt/package/flukso/config/fcheck.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# fcheck - Check whether the Flukso daemon components are still running. +# +# Copyright (C) 2011 Bart Van Der Meerssche +# +# This program 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. +# +# This program 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 this program. If not, see . +# + +[ -z "$(ps | grep 'spi[d]')" ] && exit 1 +[ -z "$(ps | grep 'flukso[d]')" ] && exit 2 + +exit 0 diff --git a/mote/v2/openwrt/package/flukso/config/flukso.init b/mote/v2/openwrt/package/flukso/config/flukso.init index 18a6d75..fadc152 100755 --- a/mote/v2/openwrt/package/flukso/config/flukso.init +++ b/mote/v2/openwrt/package/flukso/config/flukso.init @@ -35,10 +35,22 @@ start() /usr/sbin/spid /usr/sbin/fluksod + + HEARTBEAT=/usr/bin/heartbeat + FCHECK=/usr/bin/fcheck + MINUTE=$(date '+%M') + + # Tell the server we've had a reset + $HEARTBEAT 1 >&- 2>&- <&- + + # Configure cron + echo -e "$MINUTE * * * * $HEARTBEAT 0\n*/15 * * * * [ \$($FCHECK; echo \$?) -ne 0 ] && reboot" | crontab - } stop() { + crontab -r + /usr/sbin/fluksod -k /usr/sbin/spid -k