Web2py / NGINX / UWSGI:GET请求超时,错误为(110:连接超时)

时间:2018-12-01 04:27:31

标签: rest nginx uwsgi web2py

我正在将web2py与nginx和postgres db一起使用。

我的控制器:

@request.restful()
def getresult():
    response.view = 'generic.json'
    def GET(*args,**vars):
        requestBody = request.args
        #print "Str requests "+ str(request.args)
        try:
            if requestBody is None:
                resp = "No request body"
                return dict(error=resp, status=500)
            else:
                opsType = requestBody[0]
                launchid = requestBody[1]
                print("getResult Debug Result Request OPs Type %s launchid %s "%(opsType,launchid))
                opsRows = db((db.opStatus.launchId == launchid) & (db.opStatus.opsType == opsType)).select()
                print("GetResult coming after querying DB")
                for opsRow in opsRows:
                    statusCol = opsRow.status
                    detailStatusCol = opsRow.statusDetail
                    print("getResult Returns rows "+ str(statusCol) + " " + str(detailStatusCol))
                    db.commit()
                    return response.json([statusCol, detailStatusCol])

        except Exception,e:
            return response.json([str(e), status.HTTP_500_INTERNAL_SERVER_ERROR])
    return locals()

后端系统日志:

Nov 30 13:54:53 may-server uwsgi[1789]: getResult Debug Result Request OPs Type checkhealth launchid 420420
Nov 30 13:54:53 may-server uwsgi[1789]: GetResult coming after querying DB
Nov 30 13:54:53 may-server uwsgi[1789]: getResult Returns rows Completed {"Operation": "checkhealth", "10.145.157.16": {"Service Not Running": {"Service1": "Service not running on VC", "Service2": "Service not running on VC", "Services3": "Service not running on VC", "vmcam": "Service not running on VC", "netdumper": "Service not running on VC", "imagebuilder": "Service not running on VC", "rbd": "Service not running on VC"}, "Failure": {"mbcs": "Core file could not be generated.", "vcha": "Core file could not be generated.", "vsan-dps": "Core file could not be generated.", "vmcam": "Core file could not be generated.", "pschealth": "Authentication failed.", "netdumper": "Core file could not be generated.", "imagebuilder": "Core file could not be generated.", "rbd": "Core file could not be generated."}, "Cores Generation Failure": {}, "Memory Leaks": {"vmware-vpostgres": {"Chunks": "39", "Memory Leak (Bytes)": " 0x828 (2,088) "}, "lookupsvc": {"Chunks": "434", "Memory Leak (Bytes)": " 0x4730 (18,224) "}, "perfcharts": {"Chunks": "534", "Memory Leak (Bytes)": " 0x5610 (22,032) "}, "applmgmt": {"Chunks": "2215", "Memory Leak (Bytes)": " 0x21fd8 (139,224) "}, "hvc": {"Chunks": "135", "Memory Leak (Bytes)": " 0x16e8 (5,864) "}, "sps": {"Chunks": "527", "Memory Leak (Bytes)": " 0x54b8 (21,688) "}, "sca": {"Chunks": "359", "Memory Leak (Bytes)": " 0x4058 (16,472) "}, "pschealth": {"Chunks": "0", "Memory Leak (Bytes)": " 0x0 (0) "}, "statsmonitor": {"Chunks": "0", "Memory Leak (Bytes)": " 0x0 (0) "}, "analytics": {"Chunks": "1040", "Memory Leak (Bytes)": " 0xa6f0 (42,736) "}, "updatemgr": {"Chunks": "1", "Memory Leak (Bytes)": " 0x48 (72) "}, "trustmanagement": {"Chunks": "122", "Memory Leak (Bytes)": " 0x13d0 (5,072) "}, "vsan-health": {"Chunks": "75", "Memory Leak (Bytes)": " 0x708 (1,800) "}, "vmware-postgres-archiver": {"Chunks": "0", "Memory Leak (Bytes)": " 0x0 (0) "}, "rhttpproxy": {"Chunks": "0", "Memory Leak (Bytes)": " 0x0 (0) "}, "vsm": {"Chunks": "176", "Memory Leak (Bytes)": " 0x1d50 (7,504) "}, "vmonapi": {"Chunks": "40227", "Memory Leak (Bytes)": " 0xfce7
Nov 30 13:54:53 may-server uwsgi[1789]: 8 (1,035,896) "}}}}
Nov 30 13:54:53 may-server uwsgi[1789]: [pid: 7981|app: 0|req: 15027/53828] 10.29.130.2 () {40 vars in 564 bytes} [Fri Nov 30 13:54:53 2018] GET /myapp/vc_0/getresult/checkhealth/420420 => generated 72 bytes in 66 msecs (HTTP/1.1 200) 6 headers in 328 bytes (1 switches on core 0)
Nov 30 13:55:01 may-server CRON[10806]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Nov 30 13:58:46 may-server systemd-timesyncd[891]: Timed out waiting for reply from 91.189.89.199:123 (ntp.ubuntu.com).

在error.log文件中,我有:

upstream timed out (110: Connection timed out) while reading upstream, client:........upstream: "uwsgi://unix:///tmp/web2py.socket:"

在后端,我可以看到该数据库已被查询并立即返回了控制器中提到的 Print 语句的结果,该结果打印在syslog中。上游的处理时间相当少。

uwsgi[18203]: [pid: 18217|app: 0|req: 2/4] 10.104.4.117 () {40 vars in 565 bytes} [Sat Dec  1 04:42:38 2018] GET /myapp/vc_0/getresult/healthcheck/291118183413 => generated 2295 bytes in **63 msecs** (HTTP/1.1 200) 6 headers in 321 bytes (1 switches on core 0)

但是将结果返回给客户端会超时。这里做错了什么吗?

为什么成功完成数据库操作会出现超时。就像由于某些我无法理解的原因,ngnix无法将数据发送到客户端一样。

在NGINX或UWSGI中是否需要进行任何缓冲区大小设置。

请帮助。

0 个答案:

没有答案