How do I shut down a python simpleHTTPserver?

前端 未结 8 1258
太阳男子
太阳男子 2020-12-12 12:29

So I\'m trying to learn d3, and the wiki suggested that

To view the examples locally, you must have a local web server. Any web server will work;

相关标签:
8条回答
  • 2020-12-12 13:14
    MYPORT=8888; 
    kill -9 `ps -ef |grep SimpleHTTPServer |grep $MYPORT |awk '{print $2}'`
    

    That is it!

    Explain command line :

    • ps -ef : list all process.

    • grep SimpleHTTPServer : filter process which belong to "SimpleHTTPServer"

    • grep $MYPORT : filter again process belong to "SimpleHTTPServer" where port is MYPORT (.i.e: MYPORT=8888)

    • awk '{print $2}' : print second column of result which is the PID (Process ID)

    • kill -9 <PID> : Force Kill process with the appropriate PID.

    0 讨论(0)
  • 2020-12-12 13:18

    It seems like overkill but you can use supervisor to start and stop your simpleHttpserver, and completely manage it as a service.

    Or just run it in the foreground as suggested and kill it with control c

    0 讨论(0)
提交回复
热议问题