service worker stuff
This commit is contained in:
parent
1edc2efdec
commit
f2d72f782e
14
OpenTerminal.service
Normal file
14
OpenTerminal.service
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=OpenTerminal Server
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment="PORT=443"
|
||||||
|
Environment="SSL_CERT=/certs/arimelody.me/arimelody.me.crt"
|
||||||
|
Environment="SSL_KEY=/certs/arimelody.me/arimelody.me.key"
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/npm run start
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -4,8 +4,8 @@ const path = require('path');
|
||||||
const Websocket = require('ws');
|
const Websocket = require('ws');
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
cert: fs.readFileSync('./certs/cert.crt'),
|
cert: fs.readFileSync(process.env.SSL_CERT || './certs/cert.crt'),
|
||||||
key: fs.readFileSync('./certs/cert.key'),
|
key: fs.readFileSync(process.env.SSL_KEY || './certs/cert.key'),
|
||||||
}
|
}
|
||||||
|
|
||||||
const MIME_TYPES = {
|
const MIME_TYPES = {
|
||||||
|
@ -39,6 +39,7 @@ made with <3 by ari melody
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const PORT = process.env.PORT || 8080;
|
||||||
let sockets = [];
|
let sockets = [];
|
||||||
|
|
||||||
let buffer = "";
|
let buffer = "";
|
||||||
|
@ -114,7 +115,9 @@ function handle_message(msg) {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
server.listen(8080);
|
server.listen(PORT, () => {
|
||||||
|
console.log(`OpenTerminal is now LIVE on https://127.0.0.1:${PORT}!`);
|
||||||
|
});
|
||||||
|
|
||||||
function send_text(text) {
|
function send_text(text) {
|
||||||
sockets.forEach(s => s.send(text));
|
sockets.forEach(s => s.send(text));
|
||||||
|
|
Loading…
Reference in a new issue