小编Jes*_*sse的帖子

使用python socketserver如何将变量传递给处理程序类的构造函数

我想将我的数据库连接传递给EchoHandler类,但我根本无法弄清楚如何执行此操作或访问EchoHandler类.


class EchoHandler(SocketServer.StreamRequestHandler):
    def handle(self):
        print self.client_address, 'connected'

if __name__ == '__main__':
    conn = MySQLdb.connect (host = "10.0.0.5", user = "user", passwd = "pass", db = "database")

    SocketServer.ForkingTCPServer.allow_reuse_address = 1

    server = SocketServer.ForkingTCPServer(('10.0.0.6', 4242), EchoHandler)

    print "Server listening on localhost:4242..."
    try:
        server.allow_reuse_address
        server.serve_forever()
    except KeyboardInterrupt:
        print "\nbailing..."

python socketserver python-2.7

18
推荐指数
2
解决办法
1万
查看次数

为什么haproxy path_beg只有在我不访问默认站点时才有效?

我已将haproxy配置为将路径"/ rawman"重定向到我的服务器上的端口8080.它第一次工作,但是一旦我访问默认站点,它就会停止工作.默认站点在带有mod_rewrite的apache上运行,并且它正在捕获无效请求(使用codeigniter),因此当我访问http://mysite.com/rawman?foo=bar时,我没有看到重定向的站点,而是看到了默认站点.

This is my haproxy config:

    global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        maxconn 4096
        user haproxy
        group haproxy
        daemon
defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

frontend http_proxy
        bind 0.0.0.0:8090
        acl is_ast path_beg /rawman
        use_backend ast if is_ast
        default_backend mysite

backend ast
        server ast 0.0.0.0:8080

backend mysite
        server local 0.0.0.0:80
Run Code Online (Sandbox Code Playgroud)

apache haproxy

6
推荐指数
1
解决办法
5784
查看次数

标签 统计

apache ×1

haproxy ×1

python ×1

python-2.7 ×1

socketserver ×1