[Twisted-Python] Understanding the role of .tap files
Stephen Waterbury
golux at comcast.net
Thu Aug 12 21:30:18 MDT 2004
Abe Fettig wrote:
> Hi folks,
>
> I'm looking for help understanding how .tap files are meant to be used
> in production. ...
Hi Abe,
I thought I'd respond even though I'm not a guru and my
method (which hasn't yet been used in *real* production,
but I plan to use it unless someone suggests something
better ;) may not be the orthodox way.
Real twisted gurus: I trust you will set me straight if
necessary -- comments welcome! ;)
For my app, I have created a shell script that generates
the tap every time the application is started up. The
configuration options are given as arguments that are
passed thru to the tap builder ("pgertap.py", in my case).
I've included my shell script below. It's intended to be
usable as an /etc/init.d script (I'll add the functions
and runlevels when I go production).
I'll send pgertap.py if you like, but it's modeled exactly
after the example in the howto: "Writing a New Plug-In for
mktap", so if you read that you'll know all you need to know
about tap generators.
#! /bin/sh
usage='Usage: pgerd [start|startsecure|restart|restartsecure|stop]'
if [[ -z $1 ]]; then
echo $usage
exit 1
fi
if [[ -z $PGERHOME ]]; then
echo 'env var PGERHOME must be defined.'
exit 1
fi
cd $PGERHOME/logs
case $1 in
start)
# start pgerd on http://[hostname]:8080
mktap --appname=pgerd \
pger --domains=PanGalactic,NARS \
--home=$PGERHOME
twistd --no_save -l $PGERHOME/logs/pgerd.log \
-f $PGERHOME/logs/pger.tap
;;
startsecure)
# start pgerd on https://[hostname]:8080
mktap --appname=pgerd \
pger --domains=PanGalactic,NARS \
--home=$PGERHOME \
--encrypted=1
twistd --no_save -l $PGERHOME/logs/pgerd.log \
-f $PGERHOME/logs/pger.tap
;;
restart)
# restart pgerd on http://[hostname]:8080
kill `cat $PGERHOME/logs/twistd.pid`
mv $PGERHOME/logs/pgerd.log \
$PGERHOME/logs/archive/log.`date +%Y%m%d.%H.%M`
sleep 1
rm $PGERHOME/logs/*.tap
mktap --appname=pgerd \
pger --domains=PanGalactic,NARS \
--home=$PGERHOME
twistd --no_save -l $PGERHOME/logs/pgerd.log \
-f $PGERHOME/logs/pger.tap
;;
restartsecure)
# restart pgerd on https://[hostname]:8080
kill `cat $PGERHOME/logs/twistd.pid`
mv $PGERHOME/logs/pgerd.log \
$PGERHOME/logs/archive/log.`date +%Y%m%d.%H.%M`
sleep 1
rm $PGERHOME/logs/*.tap
mktap --appname=pgerd \
pger --domains=PanGalactic,NARS \
--home=$PGERHOME \
--encrypted=1
twistd --no_save -l $PGERHOME/logs/pgerd.log \
-f $PGERHOME/logs/pger.tap
;;
stop)
# stop pgerd and archive its log
kill `cat $PGERHOME/logs/twistd.pid`
mv $PGERHOME/logs/pgerd.log \
$PGERHOME/logs/archive/log.`date +%Y%m%d.%H.%M`
sleep 1
rm $PGERHOME/logs/*.tap
;;
*)
# print help and exit
echo "argument \"$1\" not recognized."
echo $usage
exit 1
;;
esac
exit 0
More information about the Twisted-Python
mailing list