Open GoogleCodeExporter opened 9 years ago
忘了补充.
因为低费用的PAAS服务器有限速和流量.所以有时候需要类似老
版那样让两到三个PAAS服务器同时缓冲才能比较方便快速的做�
��理....于是对这方面希望能做做.OTL
Original comment by kagami0...@hotmail.com
on 14 Sep 2012 at 1:29
1.
想起来了,PAAS是支持多个的,不支持同时设置多个网址,但�
��持产生多个PAAS实例(这点与GAE不同,GAE是单实例模式):
PAAS1 = paas.PAAS(url='https://demo1.app.com/', listen='8088', password='123456', proxy='http://127.0.0.1:8087/')
PAAS2 = paas.PAAS(url='https://demo2.app.com/', password='123456', proxy='http://127.0.0.1:8087/')
PAAS0 = (PAAS1, PAAS2)
from random import choice
PAAS = lambda req: choice(PAAS0)(req)
[pac]
enable = 1
;file = proxy.pac
rulelist = !rulelist
py_default = GAE
default = DIRECT
[py_rulelist]
PAAS1 = paaslist1.ini
PAAS2 = paaslist2.ini
PAAS = paaslist.ini
这样就可以paaslist1.ini走PAAS1,paaslist2.ini走PAAS2,paaslist.ini在PA
AS1与PAAS2中随机选择一个。
这里PAAS2没有单独监听端口,所以无法通过PAC访问,你可以像
PAAS1那样单独监听端口例如8089,也可以按以下方法修改为PAAS1
与PAAS2共用8088端口:
rulelist = (
(RuleList(['paaslist1.ini']), PAAS1),
(RuleList(['paaslist2.ini']), PAAS2),
)
def find_proxy_handler(req):
proxy_type = req.proxy_type
host, port = req.proxy_host
if proxy_type.endswith('http'):
url = req.url
for rule,target in rulelist:
if rule.match(url, host):
return target
return PAAS
paas.data['PAAS_server'].find_handler = find_proxy_handler
2. 以后更新时应该会加上吧;
3.
这种复杂写法要求key必须与变量名一一对应,很容易出现NameE
rror错误,所以不会过多介绍;
4. 上面的示例代码已经支持不同paaslist对应不同PAAS了
5. PAAS暂不支持多线程
Original comment by www.eh...@gmail.com
on 14 Sep 2012 at 4:40
上面的rulelist、find_proxy_handler最好换个名称,例如:
paaslist = (
(RuleList(['paaslist1.ini']), PAAS1),
(RuleList(['paaslist2.ini']), PAAS2),
)
def find_paas_handler(req):
proxy_type = req.proxy_type
host, port = req.proxy_host
if proxy_type.endswith('http'):
url = req.url
for rule,target in paaslist:
if rule.match(url, host):
return target
return PAAS
paas.data['PAAS_server'].find_handler = find_paas_handler
,总之就是写法与find_proxy_handler类似,但是是另外定义,而��
�是同一个,
最后也不是return
find_paas_handler,而是paas.data['PAAS_server'].find_handler =
find_paas_handler,
GAE的8087也可以这么改:paas.data['GAE_server'].find_handler =
find_gae_handler
Original comment by www.eh...@gmail.com
on 14 Sep 2012 at 4:48
OAA不用支持多线程,只需要能多个并发就行了..
Original comment by kagami0...@hotmail.com
on 15 Sep 2012 at 2:47
Moved to: Issue wallproxy:126
Original comment by wwqgtxx
on 2 Dec 2012 at 2:19
Original issue reported on code.google.com by
kagami0...@hotmail.com
on 14 Sep 2012 at 1:12