This PR add the ability to run the server in the background for the http server + client! It is tested to work for both localhost and Digital Ocean (DO) in both VSCODE's integrated terminal and a regular terminal.
Testing Background Server
pull the dev-sri/websocket-protocol-detach branch
npm ci && cd _ur
nohup ur net start &
close the terminal window/visual studio code
This will run the server in the background, and you can visit it from a browser.
if running on DO, browse to the location that the ursys repo is being routed to by nginx
if running locally, browse to localhost:8080
Open two or three browser windows and open the javascript console to confirm operation. The test client app self-closes out after 360 seconds. To monitor the output of the server as clients connect/disconnect, use tail -f nohup.out
Technical Information
To make this work, I had to
Add NOHUP handlers to key files, as the way the UR CLI works is by using a bash script to launch a node app that forks several children
Change the client-side connection code to pass window.location to a function to return a valid websocket connection string based on the current protocol being http or https. While nginx handles the http proxying, the connection string has to match the protocol in use otherwise Chrome throws an error.
[!WARNING]
Fixes in this PR are limited to serve-http, and have not been tested with serve-uds or serve-wss modules
This PR add the ability to run the server in the background for the http server + client! It is tested to work for both localhost and Digital Ocean (DO) in both VSCODE's integrated terminal and a regular terminal.
Testing Background Server
dev-sri/websocket-protocol-detach
branchnpm ci && cd _ur
nohup ur net start &
This will run the server in the background, and you can visit it from a browser.
localhost:8080
Open two or three browser windows and open the javascript console to confirm operation. The test client app self-closes out after 360 seconds. To monitor the output of the server as clients connect/disconnect, use
tail -f nohup.out
Technical Information
To make this work, I had to
NOHUP
handlers to key files, as the way the UR CLI works is by using a bash script to launch a node app that forks several childrenwindow.location
to a function to return a valid websocket connection string based on the current protocol beinghttp
orhttps
. While nginx handles the http proxying, the connection string has to match the protocol in use otherwise Chrome throws an error.