Wire up schema automation

This commit is contained in:
Tau 2019-10-14 22:49:36 -04:00
parent 6d91659b24
commit 799ace06d7

View File

@ -8,6 +8,7 @@ import net from "net";
import aimedb from "./aimedb";
import allnet from "./allnet";
import billing from "./billing";
import checkdb from "./checkdb";
import chunithm from "./chunithm";
import diva from "./diva";
import idz from "./idz";
@ -15,26 +16,36 @@ import idzPing from "./idz/ping";
import { openSqlite } from "./sql";
import * as Swb from "./switchboard";
fs.mkdirSync("./data", { recursive: true });
(async function() {
fs.mkdirSync("./data", { recursive: true });
const db = openSqlite("./data/db.sqlite3");
const db = openSqlite("./data/db.sqlite3");
const tls = {
cert: fs.readFileSync("pki/server.pem"),
key: fs.readFileSync("pki/server.key"),
};
try {
await checkdb(db);
} catch (e) {
console.error(e);
net.createServer(aimedb(db)).listen(Swb.PORT_AIMEDB, Swb.HOST_INT);
http.createServer(allnet).listen(Swb.PORT_ALLNET, Swb.HOST_INT);
https.createServer(tls, billing).listen(Swb.PORT_BILLING, Swb.HOST_INT);
return;
}
http.createServer(chunithm).listen(Swb.PORT_CHUNITHM, Swb.HOST_INT);
http.createServer(diva).listen(Swb.PORT_DIVA, Swb.HOST_INT);
const tls = {
cert: fs.readFileSync("pki/server.pem"),
key: fs.readFileSync("pki/server.key"),
};
net.createServer(idz(db)).listen(Swb.PORT_IDZ.USERDB.TCP, Swb.HOST_INT);
idzPing(10001, Swb.HOST_INT); // ?? tbd
idzPing(Swb.PORT_IDZ.MATCH.UDP_SEND, Swb.HOST_INT);
idzPing(Swb.PORT_IDZ.ECHO1, Swb.HOST_INT);
idzPing(Swb.PORT_IDZ.ECHO2, Swb.HOST_INT);
net.createServer(aimedb(db)).listen(Swb.PORT_AIMEDB, Swb.HOST_INT);
http.createServer(allnet).listen(Swb.PORT_ALLNET, Swb.HOST_INT);
https.createServer(tls, billing).listen(Swb.PORT_BILLING, Swb.HOST_INT);
console.log("Startup OK");
http.createServer(chunithm).listen(Swb.PORT_CHUNITHM, Swb.HOST_INT);
http.createServer(diva).listen(Swb.PORT_DIVA, Swb.HOST_INT);
net.createServer(idz(db)).listen(Swb.PORT_IDZ.USERDB.TCP, Swb.HOST_INT);
idzPing(10001, Swb.HOST_INT); // ?? tbd
idzPing(Swb.PORT_IDZ.MATCH.UDP_SEND, Swb.HOST_INT);
idzPing(Swb.PORT_IDZ.ECHO1, Swb.HOST_INT);
idzPing(Swb.PORT_IDZ.ECHO2, Swb.HOST_INT);
console.log("Startup OK");
})();