PEN - Load Balancing Port Forwarder

De Wiki Hackstore

Arquivo:

/etc/pen.cfg
# Original idea: Torsten.Goedicke@wlw.de
# Modified for SUSE LINUX by joe@suse.de

# simple configuration file for the pen loadbalancer
# BEZx="Name for instance"
# PIDx=/var/run/pen.pid-[Port]
# CONx=$HOST:800x
# PENx="-p $PIDx -C $CONx [Port] [Server1:Port] [Server2:Port]"
#

# The entries in COUNT must match the numbers used below
# i.e. if you add another instance using BEZ2, PID2, etc.
# you also have to change COUNT from "1" to "1 2".

COUNT="1"

# If want to use port 80 as in the default you can't run an Apache server
# or any otherweb server on the same port at the same time!

BEZ1="WWW Proxy"
PID1=/var/run/pen.pid-8080
CON1=192.168.0.217:3340
PEN1="-x  500 -r -w /etc/pen.html -l /var/log/pen.log -p $PID1 -C $CON1 3389 -r 192.168.0.18:3389 192.168.0.62:3389:15 192.168.0.63:3389:12"

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Arquivo:

/etc/init.d/pen
#! /bin/sh
# Copyright (c) 1995-2004 SUSE LINUX AG, Germany.
#
# Author: joe@suse.de, template by ro@suse.de
#         using parts from Torsten.Goedicke@wlw.de
#
# /etc/init.d/pen
#   and its symbolic  link
# /usr/sbin/rcpen
#
### BEGIN INIT INFO
# Provides:          pen
# Required-Start:    $time $named $syslog $remote_fs
# Required-Stop:     $time $named $syslog $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 4 6
# Short-Description: Load balancer for tcp based protocols
# Description:       A simple load balancer for tcp based protocols
### END INIT INFO

. /etc/rc.status

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

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

test -r $CF || { echo "$CF not found";
        if [ "$1" = "stop" ]; then exit 0;
    else exit 6; fi; }

. $CF

# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}

# Force execution if not called by a runlevel directory.
test -x $DAEMON || exit 0

rc_reset
case "$1" in
    start)
    PID=`$PS | grep $NAME | grep -v grep | grep -v $JOBNAME`
    if [ -n "$PID" ]; then
      echo "$NAME load balancer is already running as"
      echo "$PID"
    else
      echo -n "Starting pen load balancer instances"
      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
    fi
    rc_status -v
    ;;
    stop)
    echo -n "Shutting down pen load balancer instances"
    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
    rc_status -v
    ;;
    restart)
    echo -n "Restarting pen load balancer instances"
    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
    rc_status -v
    ;;
        reload)
                echo "Reload pen load balancer instances"
                /sbin/killproc -HUP $DAEMON
                touch $PIDFILE
                rc_status -v
        ;;
    *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
    ;;
esac
rc_exit


Site oficial do projeto:

http://siag.nu/pen