webpack-dev-server icon indicating copy to clipboard operation
webpack-dev-server copied to clipboard

Add API to close dev server

Open tricoder42 opened this issue 11 years ago • 11 comments

I'm trying to close webpack dev server programatically, so I can run it it task with webdriverio.

The webpack API already provides listen method which delegates listen call and inits socket.io. I tried to add close method with similar functionality, but couldn't get it work (the process still hangs).

Server.prototype.close = function(callback) {
    this.io.close();
    this.io = null;

    this.listeningApp.close(callback);
    this.listeningApp = null;
}

Any ideas?

tricoder42 avatar Sep 01 '15 13:09 tricoder42

Fixed

TheLarkInn avatar Aug 21 '16 06:08 TheLarkInn

Hi, How i can stop webpack-dev-server programaticaly ? like webpack-dev-server close() for example ...

cbelhaffef avatar Aug 31 '16 16:08 cbelhaffef

Like you said, with close()?

SpaceK33z avatar Aug 31 '16 17:08 SpaceK33z

i used but nothing happen.. :(

cbelhaffef avatar Aug 31 '16 17:08 cbelhaffef

Which version of dev-server are you using? Can you share the relevant part of your code?

SpaceK33z avatar Aug 31 '16 17:08 SpaceK33z

version : 1.14.1

var WebpackDevServer = require("webpack-dev-server"); var webpack = require("webpack");

`var compiler = webpack({ ...... ..... }); var server = new WebpackDevServer(compiler, {
}); server.listen(3000, "localhost", function() {});

server.close(); `

the server started but not closed.

thank you for your help.

cbelhaffef avatar Aug 31 '16 17:08 cbelhaffef

Can you try changing localhost to 127.0.0.1? This causes a lot of weird errors (see #183).

SpaceK33z avatar Aug 31 '16 17:08 SpaceK33z

Hi, nothing changed.

cbelhaffef avatar Sep 01 '16 07:09 cbelhaffef

@SpaceK33z, have the same issue, "webpack-dev-server": "^2.4.2", the server is alive even after calling stop() method. Do you have any idea why it happens?

pavel06081991 avatar Apr 05 '17 21:04 pavel06081991

Same here..

pkearney13 avatar Sep 07 '17 12:09 pkearney13

After I call the close method, the server still seems to be alive although it no longer is using the port.

ozyman42 avatar Dec 27 '18 11:12 ozyman42