[fluksod] add a crontab entry that checks up on the daemon every 15min

This commit is contained in:
Bart Van Der Meerssche 2011-04-17 22:08:56 +02:00
parent 81e3010347
commit 7b81c079f6
3 changed files with 40 additions and 0 deletions

View File

@ -51,15 +51,19 @@ define Package/flukso/install
$(INSTALL_DATA) $(PKG_BUILD_DIR)/rrd/*.lua $(1)/usr/lib/lua/rrd/ $(INSTALL_DATA) $(PKG_BUILD_DIR)/rrd/*.lua $(1)/usr/lib/lua/rrd/
$(INSTALL_DIR) $(1)/usr/lib/lua/flukso $(INSTALL_DIR) $(1)/usr/lib/lua/flukso
$(INSTALL_DATA) $(PKG_BUILD_DIR)/flukso/*.lua $(1)/usr/lib/lua/flukso/ $(INSTALL_DATA) $(PKG_BUILD_DIR)/flukso/*.lua $(1)/usr/lib/lua/flukso/
$(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/luad $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/luad $(1)/usr/sbin/
$(LN) /usr/sbin/luad $(1)/usr/sbin/fluksod $(LN) /usr/sbin/luad $(1)/usr/sbin/fluksod
$(INSTALL_BIN) $(PKG_BUILD_DIR)/fluksod.lua $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fluksod.lua $(1)/usr/sbin/
$(LN) /usr/sbin/luad $(1)/usr/sbin/spid $(LN) /usr/sbin/luad $(1)/usr/sbin/spid
$(INSTALL_BIN) $(PKG_BUILD_DIR)/spid.lua $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/spid.lua $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/bin $(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)/fsync.lua $(1)/usr/bin/fsync
$(INSTALL_BIN) $(PKG_BUILD_DIR)/fdude.lua $(1)/usr/bin/fdude $(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 $(INSTALL_BIN) $(PKG_BUILD_DIR)/restful.lua $(1)/usr/bin/restful
endef endef

View File

@ -0,0 +1,24 @@
#!/bin/sh
#
# fcheck - Check whether the Flukso daemon components are still running.
#
# Copyright (C) 2011 Bart Van Der Meerssche <bart.vandermeerssche@flukso.net>
#
# 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 <http://www.gnu.org/licenses/>.
#
[ -z "$(ps | grep 'spi[d]')" ] && exit 1
[ -z "$(ps | grep 'flukso[d]')" ] && exit 2
exit 0

View File

@ -35,10 +35,22 @@ start()
/usr/sbin/spid /usr/sbin/spid
/usr/sbin/fluksod /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() stop()
{ {
crontab -r
/usr/sbin/fluksod -k /usr/sbin/fluksod -k
/usr/sbin/spid -k /usr/sbin/spid -k