Brian Sullivan
Brian Sullivan

Reputation: 28573

How to quit ASP.NET Kestrel web server on a Mac

I'm running a simple MVC app generated by Yeoman on my Mac using the ASP.NET vNext K runtime. I can run k kestrel from the project directory, and everything boots up and runs just fine. However, when I hit Ctrl+C (or any other key combination I've tried), the server doesn't quit. I have to close the terminal window to get the server to shut down. What am I missing?

Upvotes: 37

Views: 7094

Answers (4)

Allan F. Gagnon
Allan F. Gagnon

Reputation: 320

If you have any processes open simply pressing "Enter" wont work on a mac. However if you use the example from UnraisedCesar and kill all your processes. Then restart the k kestrel you should be able to press "Enter" (if this is the only one of these processes running) and it will end properly.

Upvotes: 1

Andrew
Andrew

Reputation: 451

If simply pressing Enter doesn't work for you, try the following in the terminal window where you're running Kestrel:

  1. Hit Ctrl + z to suspend the process.
  2. Type: kill %1.

Upvotes: 45

Brian Sullivan
Brian Sullivan

Reputation: 28573

It turns out that simply hitting "Enter" exits kestrel cleanly, without the need to kill the mono-sgen process afterward. There is a github issue on the Kestrel repo asking to make this more obvious.

Upvotes: 35

UnraisedCesar
UnraisedCesar

Reputation: 81

Hit Ctrl+Z, then you will need to kill the mono-sgen process to be able to run 'k kestrel' again with the same IP:PORT (If someone knows a better way please let us know)

After "Ctrl+Z" type "ps" to list your processes and find the PID for "/Users/YOU/.kre/packages/KRE-mono45-x86.1.0.0-alpha4", for example: "123456", then type "kill 123456".

UPDATE: I tried to use 'killall mono-sgen' but doesn't works for me.

Upvotes: 8

Related Questions