I'm trying to use aspen for two simple web servers bound to different
ports, running from a single main python file.
My original plan was to call aspen.main() twice, with different '--
root=...' options,
but then I noticed that the configuration is saved globally in
aspen.__init__.py so one instance can override the setting of the
other.
I'm well aware of the restarted, and I think I tricked out of it, so
this is not the issue.
Other than duplicating the entire aspen directory to aspen1 and
aspen2, is there a way to execute two servers from a single main.py
program?
Thanks
Ori
Thanks for your mail and your experimentation.
> [I]s there a way to execute two servers from a single main.py
> program?
I would suggest you introduce a process boundary. Have your main
program launch aspen via the subprocess module, passing it the
--root and --address options you require on the command line.
chad
> I was hoping there was a way to do it in a single process...
Well, you'd just need to dig low enough into the object model.
Try instantiating two of your own website.Website objects and
passing them to two instances of wsgiserver.CherryPyWSGIServer.
chad
Well, I did it, and still there is one critical problem, which is the
globals_ defined in __init__.py
More specifically, in handlers/static.py there's an import statement
for the global "conf".
This means that both instances would use "conf", even tough they use
separate __/etc/aspen.conf.
Currently, this works for me but I can't say that I'm happy. I'm
worried that in the future I may face problems that originate from
this anomality.
I do understand that I'm not using aspen as it was intended to, but
I'd still suggest to minimize the use of globals.
Thanks for your help,
Ori
> Well, I did it, and still there is one critical problem, which is the
> globals_ defined in __init__.py
> More specifically, in handlers/static.py there's an import statement
> for the global "conf".
> This means that both instances would use "conf", even tough they use
> separate __/etc/aspen.conf.
>
> Currently, this works for me but I can't say that I'm happy. I'm
> worried that in the future I may face problems that originate from
> this anomality.
>
> I do understand that I'm not using aspen as it was intended to, but
> I'd still suggest to minimize the use of globals.
We'll have to hear more interest in this feature before we make
major changes to Aspen to support it.
Could I ask what's wrong with a process boundary?
chad