Showing posts with label webserver. Show all posts
Showing posts with label webserver. Show all posts

Sunday, February 04, 2007

python handy debug error tip

Here's a handy way to make debugging your web.py scripts a little
easier. Just add this to your main script (before you do web.run()):

def error():
if web.webapi.ctx.ip == '': web.debugerror()
else: origerror()
origerror = web.webapi.internalerror
web.webapi.internalerror = error

Add your IP address where it says. This will show detailed debug
output if an exception occurs, but only when the request is from your
IP address. Anyone else will get the usual "internal server error"
message. This is a convenient way to make your web.py app securely
debuggable without having to manually switch back and forth between
debug/deploy modes every time you want to make a change.

Tuesday, January 16, 2007

Reboot server detecting open connections

#!/bin/bash
cd /home/mark/work/pop
svn up
echo 'updated to latest code. trying restart'

#find number of active connections that are established
number_of_conn=`netstat -apn 2>&1 | grep :80 | grep -i established | wc -l`
#echo $number_of_conn

trial=0
while [ $number_of_conn -ne 0 ]
do
trial=$((trial +1 ))
echo "$number_of_conn connections: trying again"
number_of_conn=`netstat -apn 2>&1 | grep :80 | grep -i established | wc -l`
done

/home/mark/bin/startstop
echo 'there were 0 connections. restarted'
echo "number of trials: $trial"