Open typhonrt opened 7 years ago
Just a FYI... If anyone is interested in the wrapper I have created it's on NPM: typhonjs-live-server. It contains the workaround necessary to use live-server
and terminate it gracefully when embedded in a Node app in addition to providing a few other utility functions like being able to open the browser at any time. Not that this is important to most, but it also is typhonjs-plugin-manager enabled providing event bindings to control live server. I'll post more documentation soon, but just check out the source code for now: LiveServer.js.
Greets...
live-server
is great; good work...I'm embedding
live-server
into a Node app and there is an issue withopn
preventing graceful shutdown. After dealing with unref / destroying sockets to attempt graceful shutdown as noted in #169 there is still an issue withopn
. Basically to getlive-server
to shutdown gracefullywait: false
needs to be added toopn
invocation. Settingwait
to false will resolve the promise inopn
immediately including a call to cp.unref(). This separates the browser child process from the calling Node app.Since I am already wrapping
live-server
to deal with "unreffing" sockets I simply handle launching the browser / usage ofopn
directly in my wrapper as necessary always passingopen: false
tolive-server
.It seems reasonable to add optional user input into how
opn
is invoked. This includes extra options and perhaps also could address #154.In the short term I don't see any problems with adding
wait: false
toopn
invocation though I haven't run thelive-server
tests with this change.Things would change from current to: