PEN Load Balancer

Home Page: http://siag.nu/pen/
Version: 0.17.0
Description: TCP Load Balancing Port Forwarder
Portage: net-misc/pen

Start Script

#!/bin/sh
#set -x
#
# Start und Stopskript fuer den Loadbalancer Pen
#
# /etc/init.d/pen
#
# Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for exim by Tim Cutts <timc@chiark.greenend.org.uk>
# Modified for pen by Torsten Goedicke <goedicke@wlw.de>

#set -e

JOBNAME="$0"
NAME=pen
DAEMON=/usr/local/bin/run$NAME.sh
CF=/etc/$NAME.cf

case `uname` in
  SunOS) ECHOSW=""
         ECHONL="\c"
         PS="ps -ef"
         ;;
  Linux) ECHOSW="-n"
         ECHONL=""
         PS="ps x"
         ;;
  *)     ;;
esac

PIDDIR="/var/run"
PIDALL="$PIDDIR/run$NAME.pid"

if [ -f $CF ]; then
  . $CF
else
  echo "Error: Configuration file $CF not found" && exit 0
fi

test -x $DAEMON || exit 0

case "$1" in
  start)
    PID=`$PS | grep "$NAME " | grep -v grep | grep -v $JOBNAME`
    if [ -n "$PID" ]; then
      echo "Loadbalancer $NAME is already running as"
      echo "$PID"
    else
      echo $ECHOSW "Starting Loadbalancer: $ECHONL"
      for i in $COUNT
      do
        eval PIDFILE=\$PID${i}
        eval OPTIONS=\$PEN${i}
        CFFILE=`echo $PIDFILE | sed 's/pid/conf/'`
        echo $OPTIONS > $CFFILE
        $DAEMON $CFFILE &
        echo $! >> $PIDALL
      done
      echo "$NAME."
    fi
    ;;
  stop)
    echo $ECHOSW "Stopping Loadbalancer: $ECHONL"
    test -f $PIDALL && kill -TERM `cat $PIDALL` 2> /dev/null
    test -f $PIDALL && kill -KILL `cat $PIDALL` 2> /dev/null
    rm -f $PIDALL
    for i in $COUNT
    do
      eval PIDFILE=\$PID${i}
      eval OPTIONS=\$PEN${i}
      CFFILE=`echo $PIDFILE | sed 's/pid/conf/'`
      test -f $PIDFILE && kill -TERM `cat $PIDFILE` 2> /dev/null
      rm -f $PIDFILE $CFFILE
    done
    echo "$NAME."
    ;;
  restart)
    echo $ECHOSW "Restarting Loadbalancer: $ECHONL"
    for i in $COUNT
    do
      eval PIDFILE=\$PID${i}
      eval OPTIONS=\$PEN${i}
      CFFILE=`echo $PIDFILE | sed 's/pid/conf/'`
      echo $OPTIONS > $CFFILE
      kill -TERM `cat $PIDFILE`
    done
    echo "$NAME."
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
    exit 1
    ;;
esac

exit 0

Config File

# Konfigurationsfile fuer den pen loadbalancer
# BEZx="Name fuer BB"
# PIDx=/var/run/pen.pid-[Port]
# CONx=localhost:800x
# PENx="-p $PIDx -C $CONx [Port] [Server1:Port] [Server2:Port]"
#
COUNT="1 2 3 4"
#
BEZ1="HTTP"
PID1=/var/run/pen.pid-1
CON1=192.168.0.190:80
PRT1=192.168.0.190:80
PEN1="-H -l /var/log/pen -x 500 -p $PID1 $PRT1 192.168.1.191:80 192.168.1.192:80"
#
BEZ2="HTTPS"
PID2=/var/run/pen.pid-2
CON2=192.168.0.190:443
PRT2=192.168.0.190:443
PEN2="-l /var/log/pen -x 500 -p $PID2 $PRT2 192.168.1.191:443 192.168.1.192:443"
#
BEZ3="HTTP2"
PID3=/var/run/pen.pid-3
CON3=192.168.0.180:80
PRT3=192.168.0.180:80
PEN3="-H -l /var/log/pen -x 500 -p $PID3 $PRT3 192.168.1.181:80 192.168.1.182:80"
#
BEZ4="HTTPS2"
PID4=/var/run/pen.pid-4
CON4=192.168.0.180:443
PRT4=192.168.0.180:443
PEN4="-l /var/log/pen -x 500 -p $PID4 $PRT4 192.168.1.181:443 192.168.1.182:443"
pen_load_balancer.txt · Last modified: 2011/03/04 00:55 by 127.0.0.1
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki