简体   繁体   English

如何杀死蒸汽服务器

[英]How to Kill Vapor Server

I'm trying to build a very simple service using Vapor.我正在尝试使用 Vapor 构建一个非常简单的服务。 It depends on websockets, and I establish a connection between an iOS device in simulator and vapor running on localhost.它取决于 websockets,我在模拟器中的 iOS 设备和在本地主机上运行的蒸汽之间建立了连接。

When I want to make changes to the server, I restart and sometimes get [ ERROR ] bind(descriptor:ptr:bytes:): Address already in use (errno: 48)当我想对服务器进行更改时,我重新启动,有时会得到[ ERROR ] bind(descriptor:ptr:bytes:): Address already in use (errno: 48)

I don't know how to find and kill this process, which is a socket running on 8080. I have to restart to get out of it, and I feel like throwing the computer out the window after a few repetitions (question about that already asked in mentalHealthOverflow.com).我不知道如何找到并杀死这个进程,这是一个在 8080 上运行的套接字。我必须重新启动才能摆脱它,我感觉在重复几次后将计算机扔出 window(关于这个问题已经在mentalHealthOverflow.com 中询问)。

How can I find and kill this process?我怎样才能找到并杀死这个进程? Stopping the simulator device doesn't do it.停止模拟器设备不会这样做。

The fix is actually pretty easy.修复实际上很容易。 Go to your terminal and run lsof -i:<port> , so in your case, lsof -i:8080 . Go 到您的终端并运行lsof -i:<port> ,因此在您的情况下, lsof -i:8080 You will get an output of all the processes that are running on that port.您将获得在该端口上运行的所有进程的 output。

COMMAND   PID          USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Run     48904 calebkleveter   31u  IPv4 0x97c38af35a1b4785      0t0  TCP localhost:Run (LISTEN)

You can then run the kill command, passing in the PID from the output you got:然后你可以运行kill命令,从你得到的 output 中传入PID

kill 48904

You can now run your Vapor service.您现在可以运行您的 Vapor 服务。

Oneliner that I use:我使用的 Oneliner:

lsof -i :8080 -sTCP:LISTEN | awk 'NR > 1 {print $2}' | xargs kill -15

Which basically just sends PID of the Vapor process (running on port 8080) to the kill command as argument它基本上只是将 Vapor 进程(在端口 8080 上运行)的kill PID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM