So I'm trying to learn d3, and the wiki suggested that
所以我正在学习d3,*建议这么做
To view the examples locally, you must have a local web server. Any web server will work; for example you can run Python's built-in server:
要在本地查看示例,必须有一个本地web服务器。任何web服务器都可以工作;例如,您可以运行Python的内置服务器:
python -m SimpleHTTPServer 8888 &
python -m SimpleHTTPServer 8888 &
Great... only now I have a server running... but at some point I think I should probably shut that down again.
伟大的……现在我有一个服务器在运行……但在某种程度上,我认为我应该再次关闭它。
Is there a better way of shutting it down than using kill <pid>
? That seems like kind of a big hammer for a little job.
有比使用kill
(I'm running Mac OS 10.6.8 (Snow Leopard))
(我正在运行Mac OS 10.6.8(雪豹))
FWIW: ctrl+c
gives about 10 lines of traceback, complaining about being interrupted.
FWIW: ctrl+c给出了大约10行回溯,抱怨被中断。
kill -3 <pid>
gives a Finder warning in a separate window 'Python quit unexpectedly'.
kill -3
The default kill <pid>
and kill -15 <pid>
are relatively clean (and simple).
默认的kill
7 个解决方案
#1
27
You are simply sending signals to the processes. kill
is a command to send those signals.
您只是向进程发送信号。kill是发送这些信号的命令。
The keyboard command Ctrl+C (⌃
+C
) sends a SIGINT, kill -9
sends a SIGKILL, and kill -15
sends a SIGTERM.
键盘命令Ctrl + C(⌃+ C)发送一个信号情报,杀死9发送SIGKILL和杀死-15发送SIGTERM。
What signal do you want to send to your server to end it?
您希望向服务器发送什么信号来结束它?
#2
23
if you have started the server with
如果您已经启动了服务器
python -m SimpleHTTPServer 8888
then you can press ctrl + c to down the server.
然后你可以按ctrl + c到服务器。
But if you have started the server with
但是如果您已经启动了服务器
python -m SimpleHTTPServer 8888 &
or
或
python -m SimpleHTTPServer 8888 & disown
you have to see the list first to kill the process,
你必须先看到列表才能终止这个过程,
run command
运行命令
ps
or
或
ps aux | less
it will show you some running process like this ..
它会向你展示一些像这样的运行过程。
PID TTY TIME CMD
7247 pts/3 00:00:00 python
7360 pts/3 00:00:00 ps
23606 pts/3 00:00:00 bash
you can get the PID from here. and kill that process by running this command..
你可以从这里得到PID。通过运行这个命令来杀死这个进程。
kill -9 7247
here 7247 is the python id.
这里7247是python id。
Also for some reason if the port still open you can shut down the port with this command
同样,由于某些原因,如果端口仍然打开,您可以使用此命令关闭端口
fuser -k 8888/tcp
熔化炉- k 8888 / tcp
here 8888 is the tcp port opened by python.
这里是python打开的tcp端口8888。
Hope its clear now.
希望它的清楚了。
#3
14
or you can just do kill %1
, which will kill the first job put in background
或者你可以只杀死%1,这将杀死背景中的第一个作业
#4
10
MYPORT=8888;
kill -9 `ps -ef |grep SimpleHTTPServer |grep $MYPORT |awk '{print $2}'`
THat is it !!
就是这样! !
Explain command line :
-
ps -ef
: list all process.ps -ef:列出所有流程。
-
grep SimpleHTTPServer
: filter process which belong to "SimpleHTTPServer"grep SimpleHTTPServer:属于“SimpleHTTPServer”的过滤进程
-
grep $MYPORT
: filter again process belong to "SimpleHTTPServer" where port is MYPORT (.i.e: MYPORT=8888)过滤器进程属于“SimpleHTTPServer”,其中端口是MYPORT(.)。艾凡:MYPORT = 8888)
-
awk '{print $2}'
: print second column of result which is the PID (Process ID)awk '{print $2}':打印结果的第二列,它是PID(进程ID)
-
kill -9 <PID>
: Force Kill process with the appropriate PID.杀死-9
:强制杀死过程与适当的PID。
#5
3
It seems like overkill but you can use supervisor to start and stop your simpleHttpserver, and completely manage it as a service.
这看起来有点过了,但是您可以使用管理员来启动和停止simpleHttpserver,并将其完全管理为一个服务。
Or just run it in the foreground as suggested and kill it with control c
或者像建议的那样在前景中运行它然后用c控件杀死它
#6
2
Turns out there is a shutdown, but this must be initiated from another thread.
结果是有一个关闭,但这必须从另一个线程启动。
This solution worked for me: https://*.com/a/22533929/573216
这个解决方案对我起了作用:https://*.com/a/22533929/573216
#7
0
Hitting ctrl + c once(wait for traceback), then hitting ctrl+c again did the trick for me :)
按ctrl+c一次(等待traceback),然后按ctrl+c再次达到我的目的:)
#1
27
You are simply sending signals to the processes. kill
is a command to send those signals.
您只是向进程发送信号。kill是发送这些信号的命令。
The keyboard command Ctrl+C (⌃
+C
) sends a SIGINT, kill -9
sends a SIGKILL, and kill -15
sends a SIGTERM.
键盘命令Ctrl + C(⌃+ C)发送一个信号情报,杀死9发送SIGKILL和杀死-15发送SIGTERM。
What signal do you want to send to your server to end it?
您希望向服务器发送什么信号来结束它?
#2
23
if you have started the server with
如果您已经启动了服务器
python -m SimpleHTTPServer 8888
then you can press ctrl + c to down the server.
然后你可以按ctrl + c到服务器。
But if you have started the server with
但是如果您已经启动了服务器
python -m SimpleHTTPServer 8888 &
or
或
python -m SimpleHTTPServer 8888 & disown
you have to see the list first to kill the process,
你必须先看到列表才能终止这个过程,
run command
运行命令
ps
or
或
ps aux | less
it will show you some running process like this ..
它会向你展示一些像这样的运行过程。
PID TTY TIME CMD
7247 pts/3 00:00:00 python
7360 pts/3 00:00:00 ps
23606 pts/3 00:00:00 bash
you can get the PID from here. and kill that process by running this command..
你可以从这里得到PID。通过运行这个命令来杀死这个进程。
kill -9 7247
here 7247 is the python id.
这里7247是python id。
Also for some reason if the port still open you can shut down the port with this command
同样,由于某些原因,如果端口仍然打开,您可以使用此命令关闭端口
fuser -k 8888/tcp
熔化炉- k 8888 / tcp
here 8888 is the tcp port opened by python.
这里是python打开的tcp端口8888。
Hope its clear now.
希望它的清楚了。
#3
14
or you can just do kill %1
, which will kill the first job put in background
或者你可以只杀死%1,这将杀死背景中的第一个作业
#4
10
MYPORT=8888;
kill -9 `ps -ef |grep SimpleHTTPServer |grep $MYPORT |awk '{print $2}'`
THat is it !!
就是这样! !
Explain command line :
-
ps -ef
: list all process.ps -ef:列出所有流程。
-
grep SimpleHTTPServer
: filter process which belong to "SimpleHTTPServer"grep SimpleHTTPServer:属于“SimpleHTTPServer”的过滤进程
-
grep $MYPORT
: filter again process belong to "SimpleHTTPServer" where port is MYPORT (.i.e: MYPORT=8888)过滤器进程属于“SimpleHTTPServer”,其中端口是MYPORT(.)。艾凡:MYPORT = 8888)
-
awk '{print $2}'
: print second column of result which is the PID (Process ID)awk '{print $2}':打印结果的第二列,它是PID(进程ID)
-
kill -9 <PID>
: Force Kill process with the appropriate PID.杀死-9
:强制杀死过程与适当的PID。
#5
3
It seems like overkill but you can use supervisor to start and stop your simpleHttpserver, and completely manage it as a service.
这看起来有点过了,但是您可以使用管理员来启动和停止simpleHttpserver,并将其完全管理为一个服务。
Or just run it in the foreground as suggested and kill it with control c
或者像建议的那样在前景中运行它然后用c控件杀死它
#6
2
Turns out there is a shutdown, but this must be initiated from another thread.
结果是有一个关闭,但这必须从另一个线程启动。
This solution worked for me: https://*.com/a/22533929/573216
这个解决方案对我起了作用:https://*.com/a/22533929/573216
#7
0
Hitting ctrl + c once(wait for traceback), then hitting ctrl+c again did the trick for me :)
按ctrl+c一次(等待traceback),然后按ctrl+c再次达到我的目的:)