question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to stop server, mid process?

See original GitHub issue

Hi, when using webpack’s HMR, and changing the server’s port, it leaves the previous Koa server still in tact on another port.

How can I stop the Koa server mid-stage, allowing HMR to restart another one?

Is there a koa.close like there is a server.close?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

58reactions
metruecommented, Apr 19, 2016

@juliangruber 's solution totally works, but here is a simpler one.

  const app = new Koa();
  const _server = app.listen(3000);  // start


 _server.close();   // stop

10reactions
juliangrubercommented, Feb 15, 2016

this should do the trick:

var destroyable = require('server-destroy');
var http = require('http');

var server = http.createServer(app.callback());
server.listen();
destroyable(server);

// then
server.destroy();

for more questions like this, please post on stackoverflow because it’s more about usage than bugs or improvements to koa.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manually start, stop, and restart a MID Server
If you did not start the MID Server at the end of the installation procedure, you can manually start the MID Server.
Read more >
Stopping Servers and Processes - Oracle Help Center
Change to the following directory in your Oracle Analytics Server instance: (Linux) DOMAIN_HOME/bitools/bin; (Windows) DOMAIN_HOME\bitools\bin.
Read more >
How to kill a process or stop a program in Linux
Using the command line/termination characters · Ctrl + C · Ctrl + Z.
Read more >
How to safely shutdown a server in Go | by Farhan Ali Khan
Shutdown gracefully shuts down the server without interrupting any active connections. Shutdown works by first closing all open listeners, then ...
Read more >
How to kill server when seeing “EADDRINUSE: address ...
Open the Task Manager application (taskman.exe), from either the Processes or Services tab sort by the PID column. To display the PID column, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found