using aspen for multiple servers in a single process

4 views
Skip to first unread message

orish

unread,
Jul 5, 2007, 9:53:37 AM7/5/07
to aspen-users
Hello,

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

Chad Whitacre

unread,
Jul 5, 2007, 10:21:27 PM7/5/07
to orish, aspen-users
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

Ori Shalev

unread,
Jul 5, 2007, 11:59:34 PM7/5/07
to Chad Whitacre, aspen-users

I was hoping there was a way to do it in a single process...
thanks anyway

Ori



2007/7/6, Chad Whitacre <ch...@zetaweb.com>:



--

בקרו באתר שלי: http://www.cansucansu.co.il

Chad Whitacre

unread,
Jul 6, 2007, 6:51:00 AM7/6/07
to Ori Shalev, aspen-users
Ori,

> 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

orish

unread,
Jul 9, 2007, 5:32:35 AM7/9/07
to aspen-users

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

Chad Whitacre

unread,
Jul 9, 2007, 6:14:38 AM7/9/07
to orish, aspen-users
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

Reply all
Reply to author
Forward
0 new messages