Wtx ~ Wt Extension Library
WtxLib
Using 'monit' to keep your server running
Monit lines (for process charts.wt listening on port 1417):
check process charts.wt
with pidfile /home/wt/project/wt-deployed/run/charts.wt.pid
start program = "/home/wt/project/wthttpd.sh start /home/wt/project/wt-deployed/charts/charts.wt /charts.wt 1417"
stop program = "/home/wt/project/wthttpd.sh stop /home/wt/project/wt-deployed/charts/charts.wt"
if failed port 1417 protocol http request /monittoken then restart
wthttpd.sh script:
#!/bin/bash
if [ $# '<' "2" ]; then
echo $"Usage: wthttpd.sh {start|stop} /path/to/app.wt ..."
exit 1
fi
if [ ! -f $2 ]; then
echo $"Could not locate application: $2";
exit 1
fi
exe=`basename $2`
dir=`dirname $2`
exname=`basename $dir`
export APPROOT=/home/wt/project/approot
export LD_LIBRARY_PATH=/usr/local/lib
export PATH=/usr/local/bin:$PATH
#export MALLOC_CHECK_=2
case "$1" in
start)
if [ $# != "4" ]; then
echo $"Usage: wthttpd.sh start /path/to/app.wt path port"
exit 1
fi
cd $dir;
touch docroot/monittoken;
ulimit -c unlimited;
ulimit -s 1024;
./$exe -p ../run/$exe.pid --deploy-path $3 --http-port $4 \
--docroot 'docroot;/css,/resources,/icons,/favicon.ico' \
--approot $APPROOT/$exname `cat argv` >> ../run/$exe.log 2>&1 &
sleep 1;
;;
stop)
if [ $# != "2" ]; then
echo $"Usage: wthttpd.sh stop /path/to/app.wt"
exit 1
fi
cd $dir;
pid=`cat ../run/$exe.pid`;
kill $pid;
sleep 3;
kill -9 $pid;
sleep 1;
;;
*)
echo $"Usage: wthttpd.sh {start|stop} /path/to/app.wt ..."
exit 1
esac