Corriendo varias aplicaciones TG en CherryPy
maram
maramsis en gmail.com
Vie Jun 30 00:52:13 CEST 2006
El jue, 29-06-2006 a las 19:10 +0200, nocreyente escribió:
> >
> > A la hora de ahorrar recursos cargando varias aplicaciones de
> > turbogears, creo que lo mejor es tratar de cargar un solo proceso.
> > Parece ser que cherrypy 2.2 ya esta preparado para hacer esto. Ver:
> > http://www.cherrypy.org/wiki/UpgradeTo2.2
...'Multiple apps and virtual paths
Mounting a CherryPy app at a mount point determined at runtime was very
difficult in 2.1. There's a new _cptree.Tree class in 2.2 to make this
easier. In general, you should stop writing
cherrypy.root = Root()
and instead write
cherrypy.tree.mount(Root(), baseurl="/path/to/app", conf=config)
This new method will mount your app at the appropriate branch on the
cherrypy.root tree, and will also auto-prefix the section-paths in the
config dict you supply. If you don't supply the baseurl arg, it will
look for a "mount_point" config entry in [global] and use that...'
> > http://www.cherrypy.org/ticket/145
...' It's my understanding that you want Paste to manage the actual
creation of applications. If you want to create a CherryPy application,
call:
cherrypy.tree.mount(rootObject, baseurl, conf)
cherrypy.tree.mount(rootObject2, baseurl2, conf2)
cherrypy.server.start(initOnly=True, serverClass) ...'
> >
> > Supongo que tendras que configurar la variable server.webpath
> > http://www.turbogears.org/preview/docs/deployment/config.html
> >
> > y tendras que hacerte un script para cargar todas tus aplicaciones.
> > Puedes usar los scripts start-<aplicacion>.py de ejemplo.
> >
> > El codigo fuente de la funcion turbogears.start_server() lo tienes
> > en http://trac.turbogears.org/turbogears/browser/trunk/turbogears/
> > startup.py
> >
> > Si tienes algun problema dilo para ayudarte, porque antes o despues
> > tendre que hacerlo ;-)
je je podrias hacerlo tu primero... que yo lo copio ;D
no avance mucho... me complica con los seteos de TG y los de CP, pero
veamos...
tengo un script "start.py" ubicado en: /home/marcelo/svn/ para lanzar
varias app de TG.
que contiene:
=== start.py ===
#!/usr/bin/env python
import pkg_resources
pkg_resources.require("TurboGears")
import turbogears
import cherrypy
cherrypy.lowercase_api = True
cherrypy.tree.mount(Root1(), baseurl="/home/marcelo/svn/app1/trunk",
conf="app.config")
cherrypy.tree.mount(Root2(), baseurl="/home/marcelo/svn/app2/trunk",
conf="app.config")
=== end ===
Una aplicacion correra en el pto 8080 y el otro en 8081 segun dice
dev.cfg
ahora:
como le digo en start.py de donde sacar Root1() y Root2()?
antes lo hacia con un script similar al siguiente para cada aplicacion:
=== start-app1.py ===
#!/usr/bin/env python
import pkg_resources
pkg_resources.require("TurboGears")
import turbogears
import cherrypy
cherrypy.lowercase_api = True
from os.path import *
import sys
turbogears.update_config(configfile="dev.cfg", modulename="app.config")
from app.controllers import Root
cherrypy.root = Root()
cherrypy.server.start()
=== end ===
los archivos de configuracion tipicos de TG, estan en:
/home/marcelo/svn/app1/trunk/dev.cfg
/home/marcelo/svn/app1/trunk/app/config/app.cfg
------------ próxima parte ------------
_______________________________________________
Python-es mailing list
Python-es en aditel.org
http://listas.aditel.org/listinfo/python-es
Más información sobre la lista de distribución Python-es