Webpack-dev-server: Add API to close dev server

Created on 1 Sep 2015  路  11Comments  路  Source: webpack/webpack-dev-server

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?

All 11 comments

Fixed

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

Like you said, with close()?

i used but nothing happen.. :(

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

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.

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

Hi,
nothing changed.

@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?

Same here..

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daryn-k picture daryn-k  路  3Comments

uMaxmaxmaximus picture uMaxmaxmaximus  路  3Comments

antoinerousseau picture antoinerousseau  路  3Comments

adiachenko picture adiachenko  路  3Comments

tulika21-zz picture tulika21-zz  路  3Comments