【问题标题】:"python http server" automatically shut down due to“python http server”自动关闭由于
【发布时间】:2013-09-08 18:20:03
【问题描述】:
nohup python -m SimpleHTTPServer 80 &

执行上述命令后,创建http服务器 linux vps中的http服务器经常会被自动杀死(大概一到两个小时),这是为什么呢?


nohup

36.19.96.16 - - [05/Sep/2013 03:20:49] "GET /images/1.jpg HTTP/1.1" 200 - 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 640, in __init__
    self.finish()
  File "/usr/lib/python2.7/SocketServer.py", line 693, in finish
    self.wfile.flush()
  File "/usr/lib/python2.7/socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
hsb-110-81.hotspotbroadband.com - - [05/Sep/2013 06:39:54] code 400, message Bad HTTP/0.9 request type ('\x80w\x01\x03\x01\x00N\x00\x00\x00')

【问题讨论】:

  • 回溯说什么?在您运行此命令的目录中应该有一个nohup.out 文件。
  • SimpleHTTPServer 实际上不应该用作这样的网络服务器。它是单线程的,速度慢,而且不能容错。如果需要静态资源的网络服务器,请使用 Nginx

标签: python http kill-process


【解决方案1】:

试试 nohup python -m SimpleHTTPServer 80 &

并尝试在 nohup.out 日志中进行调试可能是一些内存限制,它会被杀死。

【讨论】:

  • error: [Errno 32] Broken pipe 我觉得作为 pythong SimpleHTTPServer 非常慢,加载没有图像的页面需要几秒钟。我建议你可以使用 node.js这个链接也可以更有帮助stackoverflow.com/questions/12905426/…
猜你喜欢
  • 2016-08-07
  • 2015-04-02
  • 1970-01-01
  • 1970-01-01
  • 2010-10-04
  • 1970-01-01
  • 1970-01-01
  • 2017-09-24
  • 1970-01-01
相关资源
最近更新 更多