2014-09-03 89 views
3

我使用燒瓶服務器來從服務器提供靜態文件,但偶爾服務器變得完全沒有響應,下載文件不斷下載。當我打開終端時,發現了一些奇怪的請求,我點擊CTRL + C,服務器立即變得響應,下載繼續。這種情況經常發生,我不知道是什麼導致了這種情況,以及如何防止它凍結我的燒瓶服務器,這是有人試圖破解?燒瓶:服務器在一段時間後變得沒有響應

[email protected]:~/worker# python server.py 
* Running on http://0.0.0.0:80/ 
93.134.13.318 - - [03/Sep/2014 02:07:18] code 400, message Bad request syntax ('\x00') 
93.134.13.318 - - [03/Sep/2014 02:07:18] "" 400 - 
93.134.13.318 - - [03/Sep/2014 02:07:19] "GET http://httpheader.net HTTP/1.1" 404 - 
93.134.13.318 - - [03/Sep/2014 02:07:40] code 400, message Bad request syntax ('\x04\x01\x00P\xc6\xce\x0eu0\x00') 
93.174.93.218 - - [03/Sep/2014 02:07:40] "P��u0" 400 - 
^C---------------------------------------- 
Exception happened during processing of request from ('93.174.93.218 ', 45082) 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock 
    self.process_request(request, client_address) 
    File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request 
    self.finish_request(request, client_address) 
    File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request 
    self.RequestHandlerClass(request, client_address, self) 
    File "/usr/lib/python2.7/SocketServer.py", line 638, in __init__ 
    self.handle() 
    File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 200, in handle 
    rv = BaseHTTPRequestHandler.handle(self) 
    File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle 
    self.handle_one_request() 
    File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 231, in handle_one_request 
    self.raw_requestline = self.rfile.readline() 
    File "/usr/lib/python2.7/socket.py", line 447, in readline 
    data = self._sock.recv(self._rbufsize) 
KeyboardInterrupt 
---------------------------------------- 
42.36.63.90 - - [03/Sep/2014 03:21:20] "GET/HTTP/1.1" 404 - 
63.63.193.195 - - [03/Sep/2014 03:21:20] "GET/HTTP/1.1" 404 - 

回答

2

我有同樣的問題。在python server.py中運行時,在django/flask應用程序中掛起是很常見的,因爲這不是它們的最佳環境。僅用於測試目的。當你完成它並想要發佈時,你應該把它放在wsgi/uwsgi + apache/nginx後面,你的問題就會消失。

http://flask.pocoo.org/docs/0.10/deploying/uwsgi/