Better attempt for websocket/TLS compatibility
This commit is contained in:
parent
466f897c58
commit
ba84695d13
|
@ -42,8 +42,8 @@ app.get("/:lang", (req, res) => {
|
||||||
app.use("/css", express.static(appRoot.path + "/frontend/styles"));
|
app.use("/css", express.static(appRoot.path + "/frontend/styles"));
|
||||||
app.use("/js", express.static(appRoot.path + "/frontend/out"));
|
app.use("/js", express.static(appRoot.path + "/frontend/out"));
|
||||||
|
|
||||||
function addWebsocket(baseApp) {
|
function addWebsocket(baseApp: express.Express, httpsServer: https.Server) {
|
||||||
const app = ws(baseApp).app;
|
const app = ws(baseApp, httpsServer).app;
|
||||||
app.ws("/api/v1/ws", (ws, req) => {
|
app.ws("/api/v1/ws", (ws, req) => {
|
||||||
const lang = getQueryParams(req).get("lang");
|
const lang = getQueryParams(req).get("lang");
|
||||||
if (!lang) {
|
if (!lang) {
|
||||||
|
@ -70,19 +70,17 @@ function addWebsocket(baseApp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useTLS) {
|
if (useTLS) {
|
||||||
addWebsocket(
|
const httpsServer = https.createServer(
|
||||||
https.createServer(
|
{
|
||||||
{
|
key: Buffer.from(process.env.TLS_PRIVATE_KEY, "base64").toString("ascii"),
|
||||||
key: Buffer.from(process.env.TLS_PRIVATE_KEY, "base64").toString(
|
cert: Buffer.from(process.env.TLS_CERTIFICATE, "base64").toString(
|
||||||
"ascii"
|
"ascii"
|
||||||
),
|
),
|
||||||
cert: Buffer.from(process.env.TLS_CERTIFICATE, "base64").toString(
|
},
|
||||||
"ascii"
|
app
|
||||||
),
|
);
|
||||||
},
|
addWebsocket(app, httpsServer);
|
||||||
app
|
httpsServer.listen(tlsPort, host, () =>
|
||||||
)
|
|
||||||
).listen(tlsPort, host, () =>
|
|
||||||
console.log(`Listening on https://${host}:${tlsPort}`)
|
console.log(`Listening on https://${host}:${tlsPort}`)
|
||||||
);
|
);
|
||||||
http
|
http
|
||||||
|
@ -96,7 +94,8 @@ if (useTLS) {
|
||||||
console.log(`Listening on http://${host}:${port}`)
|
console.log(`Listening on http://${host}:${port}`)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
addWebsocket(app).listen(port, host, () =>
|
addWebsocket(app, undefined);
|
||||||
|
app.listen(port, host, () =>
|
||||||
console.log(`Listening on http://${host}:${port}`)
|
console.log(`Listening on http://${host}:${port}`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,11 @@ with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
subprocess.run(["make", "image-prod"], check=True)
|
subprocess.run(["make", "image-prod"], check=True)
|
||||||
subprocess.run(["scripts/install-scripts.bash"], check=True)
|
subprocess.run(["scripts/install-scripts.bash"], check=True)
|
||||||
subprocess.run(["docker", "system", "prune", "-f"], check=True)
|
subprocess.run(["docker", "system", "prune", "-f"], check=True)
|
||||||
|
existing_containers = subprocess.run(
|
||||||
|
["docker", "ps", "-q"], check=True, stdout=subprocess.PIPE
|
||||||
|
).output.splitlines()
|
||||||
|
if existing_containers:
|
||||||
|
subprocess.run(["docker", "kill", *existing_containers], check=True)
|
||||||
subprocess.run(["systemctl", "restart", "riju"], check=True)
|
subprocess.run(["systemctl", "restart", "riju"], check=True)
|
||||||
|
|
||||||
print("==> Successfully deployed Riju! <==", file=sys.stderr)
|
print("==> Successfully deployed Riju! <==", file=sys.stderr)
|
||||||
|
|
Loading…
Reference in New Issue