Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added: 'wss' to reloadReturn #148

Merged
merged 1 commit into from
Jun 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ An **object** containing:
|----------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| reload | function | A function that when called reloads all connected clients. For more information see [manually firing server-side reload events](#manually-firing-server-side-reload-events). |
| startWebSocketServer | function | Starts and opens the WebSocket server required for reload. Only active when using the optional parameter `webSocketServerWaitStart`. Read the [parameters](#table-of-options-for-reload-opts-parameter) for more information |
| wss | object | Web socket server used for hot reload. |

You need `reloadReturn.wss.close()`, if you want automatic rebuild and restart of server code
independently, while preserving a front-end bundle already built by [WebPack](https://webpack.js.org/), for example.
To make it happen, old _express app_ should be discarded, a new one instantiated and bound to _reload_ again.
But without closing _wss_ first, an `EADDRINUSE` exception would be thrown.

Using reload as a command line application
---
Expand Down
1 change: 1 addition & 0 deletions lib/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ module.exports = function reload (app, opts, server) {
'reload': function () {
sendMessage('reload')
},
'wss': wss,
'startWebSocketServer': function () {
if (webSocketServerWaitStart) {
startWebSocketServer()
Expand Down