You can definitively handle this with one single web2py instance and you would save lots of memory (not CPU, only memory, but it may be worth).
Since you are using this in production, my recommendation is to use nginx and use nginx.conf to map subdomains into apps. Each domain would have it panel. When a new domain is created your program would add an entry to nginx.conf and restart it. No need to restart or use multiple uwsgi. This is really more of a ngnix config issue than a web2py programming issue. Massimo On Saturday, 21 March 2015 08:55:15 UTC-5, Lisandro wrote: > > Hello Massimo. I'm not really sure about my answer, but that's a question > I've asked myself in the past. > > Let me clarify: in my company we offer auto-administrable websites (for > newspapers, magazines, organizations, bloggers). What we have is a main > web2py app called "panel", that is pretty much like a CMS. In the other > hand, we have a bunch of other web2py apps that we call the "templates". > > So, when a new client arrives, he chooses one of the templates, and then I > run a script that I made to create the website. In resume, this is what the > script does: > - download and uncompress web2py.zip > - install "panel" app > - install the choosen template and symlink it to "init" app > - create database and initialize configuration variables > > So, each on of those 15 websites that I was talking about consists of: > - the main "panel" > - the "init" application, symlinked to the template that has been choosen > by the client. > > The "panel" app is accesed via domain.com/panel, and is the place where > our client can access to manage the content of his website, that is, news, > videos, polls, etc. > In the other hand, the "init" app is the public part of the website, and > it controls which data is shown and how. > > So, when we were starting this project, I decided to go with multiple > instances of web2py. However, I had my doubts about being possible to > execute all the websites with one only web2py instance. But there were too > much points that I wouldn't be able to resolve without professional help, > for example: > - How do I configure routes.py to serve multiple "panel" apps installed > with different name but being accesed via /panel url? > - What about multiple uwsgi applications? That is, multiple > wsighandler.py files. Where should they be placed assuming that I need one > per website? > - What about adding and deleting applications on production without > restarting? > > I must say that I'm completely sure that there are a lot of things to > improve to my app, and I would really like the assisante of a "web2py > expert" (also I would like to hear some suggestions of a server > administrator, and a database administrator too). However here in Argentina > there isn't official support of web2py (I think), and if there is, it's in > Buenos Aires, but I'm far away from there. > > I would really like to "open" my code to more advanced > programmers/engineers, because the next step I want to cover is the > creation of a website from a website. I mean, I'm working on the official > website of my company, where the clients would be able to create their > website in seconds (this is where my scripts would run on the back, > creating a new instance of web2py, installing the apps, creating the > database, configuring the virtual host, etc). But "opening" the code is > still something to discuss with the other members of the company, so.. > > Finally, I must say that I really appreciate any tip or sugestion, but I > understand that I would have to be more specific to get more specific tips. > > As always, thanks a lot for the help, this community is awesome, I have > always been able to solve my problems with the help received here :) > > > > El viernes, 20 de marzo de 2015, 20:47:45 (UTC-3), Massimo Di Pierro > escribió: >> >> You say "I'm using we2py in production to serve about 15 websites, each >> one of them is served by it's own web2py installation." Why? Why not a >> single web2py running? Do the difference instances run on the same server >> and different ports? >> >> On Friday, 20 March 2015 17:33:15 UTC-5, Lisandro wrote: >>> >>> I'm using we2py in production to serve about 15 websites, each one of >>> them is served by it's own web2py installation. >>> >>> I want to clean up expired sessions every certain amount of time. To do >>> that, I create a file under /etc/cron.d/ for every website. The file has >>> the following content: >>> >>> MAILTO=root >>> */60 * * * www-data nohup python /var/www/mywebsite/web2py.py -S init >>> -M -R /var/www/mywebsite/scripts/sessions2trash.py -A -o >>> */60 * * * www-data nohup python /var/www/mywebsite/web2py.py -S panel >>> -M -R /var/www/mywebsite/scripts/sessions2trash.py -A -o >>> >>> As you can see, the cleaning is executed one per hour. I'm using two >>> lines for each websites, because each website has two web2py applications >>> running: "init" and "panel", so I clean up sessions of both of them. >>> >>> The problem is that, if I activate those lines in cron configuration, >>> every time they are executed I can see that memory usage of my sever goes >>> "to the sky" (memory is all used and the server starts to swap), also the >>> CPU load increases considerably, and during about 5 o 10 minutes, all the >>> websites throw errors. >>> >>> If I execute those lines manually, they execute and finish instantly. I >>> mean, there aren't too much sessions to cleanup, so the cleaning takes no >>> more than a few seconds. So I don't understand why the same process isn't >>> working when called from cron. Any tip on this? Thanks in advance! >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.