It won't be easy... First of all I've put all parts of a new system together:
- CherryPy 3.1.2 for "pythonization"
- SQLObject 0.10.2 as out ORM
- Cheetah 2.2.2 for templates
- sqlite or mysql for db back-end (still not decided)
I want to run CherryPy application in a standalone server, probably as a deamon, on our www host and communicate with it using apache + mod_proxy.
- deamonization
Sound easy but it took me two days to understand cherryd usage. After that I've wrote a shell script to run my CherryPy application as a deamon under Fedora (I hope it would work also under RHEL..):
#!/bin/sh
#
# Comments to support chkconfig on RedHat Linux
# chkconfig: 35 96 96
# description: Cherrypy start/stop script
#
#
### BEGIN INIT INFO
# Provides: cherrypy
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2345
# Default-Stop: 90
# Short-Description: run CherryPy web server
# Description: CherryPy is a python framerwork for CMT
#
### END INIT INFO
. /etc/init.d/functions
serverdir=/home/cibak/CheRTTyPy
prog=get
server=${serverdir}/get.py
config=${serverdir}/conf/get.conf
pidfile=${PIDFILE-/var/run/CheRTTyPy.pid}
lockfile=${LOCKFILE-/var/lock/subsys/CheRTTy}
PYTHONPATH=${serverdir}
RETVAL=0
start() {
echo -n "Starting $prog:"
cherryd -d -p ${pidfile} -c ${config} -i get
RETVAL=$?
[ $RETVAL = 0 ] && touch ${lockfile}
echo_success
echo
return $RETVAL
}
stop() {
echo -n "Stopping $prog:"
if test -f ${pidfile}; then
killproc -p ${pidfile} -d 10 $prog
rm -f "$pidfile"
RETVAL=$?
else
RETVAL=1
fi
RETVAL=$?
echo_success
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $server
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
- apache and mod_proxy
I want to run CherryPy app behind apache and use mod_proxy to redirect ajax calls to it. So the vhost configuration:
<VirtualHost cibak.fedora12.mbp:443>
ServerAdmin krzysztof.ciba@xxxxxxxxx.xxx
ServerName cibak.fedora12.mbp
ProxyPreserveHost On
DocumentRoot /home/cibak/CheRTTyPy
ErrorLog logs/cibak.fedora12.mbp_error.log
TransferLog logs/cibak.fedora12.mbp_access.log
SSLEngine On
SSLProtocol all -SSLv2
SSLProxyEngine On
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass /query/ https://127.0.0.1:8083/
ProxyPassReverse /query/ https://127.0.0.1:8083/
</VirtualHost>
- ORM
SQLObject, looks pretty nice, especially sqlbuilder classes for constructing SQL query. For prototype I choose simple sqlite3 DB-API, as it is already built in python, but for production version I'll switch to ORACLE or mysql.
BTW switch of db back-end is very easy with SQLObject ORM — only place for that is changing connection string passed to sqlconnector. :)
After 6-7 weeks of rather extensive work the prototype for Atlas experiment RTT web page is ready and released to the public. Now I'm waiting for the feedback.
!!!WORK IN PROGRESS!!!
Brak komentarzy:
Prześlij komentarz