Permalink
Browse files

Added script for killing ZK leader

  • Loading branch information...
dmontag committed Nov 18, 2011
1 parent a420cb7 commit e9a6a8078cc7aa5bffce73eb24004df7df3b7323
Showing with 18 additions and 0 deletions.
  1. +18 −0 kill-zk-if-leader.sh
View
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+SERVER_ID=`cat /opt/neo4j-enterprise-1.5/conf/neo4j.properties | grep server_id | tr '=' ' ' | awk '{print $2}'`
+
+if [ ! "`./status.rb | grep -E '(leader|follower)' | wc -l`" -eq 3 ]; then
+ exit
+fi
+
+if [ ! -z "`./status.rb | grep "$SERVER_ID @" | grep leader`" ]; then
+ PID=`cat /opt/neo4j-enterprise-1.5/data/neo4j-coord.pid`
+ echo "Killing ZK leader process: $PID (id=$SERVER_ID)"
+ sleep 10
+ kill -9 $PID
+ sleep 1
+ echo "Restarting Neo4j"
+ /opt/neo4j-enterprise-1.5/bin/neo4j-coordinator start
+fi
+

0 comments on commit e9a6a80

Please sign in to comment.