Permalink
Browse files

preliminary tests passing

  • Loading branch information...
1 parent d9f0605 commit b4361dff929812ceded3749879320020cd9a3b4e BuzzTroll committed Sep 2, 2010
@@ -4,6 +4,7 @@ count=$1
if [ "X$1" == "X" ]; then
count=1
fi
+pidfile=$2
dir=`dirname $0`
cd $dir/..
@@ -16,15 +17,16 @@ fi
# so that we pick up the ini file
export LANTORRENT_HOME=$pypath
-
+delim=""
+ports_str=""
rm -f $LANTORRENT_HOME/tests/xinetd.d/*
for i in `seq 1 $count`
do
PORT=$RANDOM
while [ $PORT -lt 2048 ];
do
- $PORT=$RANDOM
+ PORT=$RANDOM
x=`netstat -l --tcp --numeric-ports | grep $PORT`
if [ "X$x" != "X" ]; then
$PORT=0
@@ -33,16 +35,21 @@ do
SERVNAME="lantorrent$PORT"
+ ports_str="$ports_str$delim$PORT"
+ delim=","
echo "s/@PORT@/$PORT/"
echo "s/@SERVICENAME@/$SERVNAME/"
echo "s^@LANTORRENT_HOME@^$LANTORRENT_HOME^"
sed -e "s/@PORT@/$PORT/" -e "s/@SERVICENAME@/$SERVNAME/" -e "s^@LANTORRENT_HOME@^$LANTORRENT_HOME^" $LANTORRENT_HOME/etc/lantorrent.inet.in | tee $LANTORRENT_HOME/tests/xinetd.d/$SERVNAME
done
+echo "export LANTORRENT_TEST_PORTS=$ports_str" > $LANTORRENT_HOME/tests/ports_env.sh
+
ls -l $LANTORRENT_HOME/tests/xinetd.d/
echo "s^@LANTORRENT_HOME@^$LANTORRENT_HOME^"
sed "s^@LANTORRENT_HOME@^$LANTORRENT_HOME^" $LANTORRENT_HOME/etc/xinetd.conf.in | tee $LANTORRENT_HOME/tests/xinetd.conf
-exec xinetd -d -f $LANTORRENT_HOME/tests/xinetd.conf -dontfork
+pidfile=$2
+exec xinetd -f $LANTORRENT_HOME/tests/xinetd.conf -pidfile $pidfile
File renamed without changes.
File renamed without changes.
@@ -56,8 +56,9 @@ def __init__(self):
self.load_settings(ini_file)
except:
emsg = "failed to load %s, using defaults" % (ini_file)
- log(logging.WARNING, emsg)
+ log(logging.WARNING, emsg, traceback)
logging.basicConfig(filename=self.logfile, level=self.log_level)
+ log(logging.WARNING, "logging to %s at %d" % (self.logfile, self.log_level))
def set_defaults(self):
self.pw = "nimbus"
@@ -76,9 +77,15 @@ def load_settings(self, ini_file):
s = SafeConfigParser()
s.readfp(open(ini_file, "r"))
self.pw = s.get("security", "password")
- self.logfile = s.get("log", "file").replace("@LANTORRENT@", self.lt_home)
- self.host = s.get("host", "host")
- self.port = s.getint("port", "port")
+ self.logfile = s.get("log", "file").replace("@LANTORRENT_HOME@", self.lt_home)
+ try:
+ self.host = s.get("host", "host")
+ except Exception, ex:
+ pass
+ try:
+ self.port = s.getint("port", "port")
+ except Exception, ex:
+ pass
try:
log_level_str = s.get("log", "level")
self.log_level = log_levels[log_level_str]
@@ -55,7 +55,7 @@ def send_header(self, destinations):
return
header = {}
- header[files] = self.file
+ header['file'] = self.file
header['host'] = self.host
header['port'] = self.port
header['id'] = self.rid
@@ -181,6 +181,7 @@ def store_and_forward(self):
def main(argv=sys.argv[1:]):
+ pylantorrent.log(logging.INFO, "server starting")
try:
v = LTServer(sys.stdin, sys.stdout)
v.store_and_forward()

0 comments on commit b4361df

Please sign in to comment.