summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-03-01 16:05:01 -0300
committerEuAndreh <eu@euandre.org>2024-03-01 16:05:19 -0300
commite37cdb0dd9bb201220a2d67ed8f56dd7c67882c4 (patch)
treeed2c6452cefdb1adce6e810864311b066428563f
parentsrc/api.mjs: Simplify handling of arguments (diff)
downloadpapod-e37cdb0dd9bb201220a2d67ed8f56dd7c67882c4.tar.gz
papod-e37cdb0dd9bb201220a2d67ed8f56dd7c67882c4.tar.xz
src/ircd.mjs: Remove unix socket before recreating it
-rw-r--r--Makefile1
-rw-r--r--src/ircd.mjs14
2 files changed, 10 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index d4719ef..e0789d3 100644
--- a/Makefile
+++ b/Makefile
@@ -136,7 +136,6 @@ uninstall:
run-ircd: all
- rm -f ircd.sock
./src/bin.mjs ircd ircd.sock
run-web: all
diff --git a/src/ircd.mjs b/src/ircd.mjs
index af4d280..1924350 100644
--- a/src/ircd.mjs
+++ b/src/ircd.mjs
@@ -1,13 +1,19 @@
+import fs from "node:fs";
import net from "node:net";
+import * as hero from "./hero.mjs";
+
+
const server = net.createServer(socket => {
socket.write("olar\r\n");
socket.pipe(socket);
});
-export const app = async udsPath => {
- await db.init();
- server.listen(udsPath, () => {
- console.log("I'm ircd.");
+export const app = async path => {
+ if (fs.existsSync(path)) {
+ fs.unlinkSync(path);
+ }
+ server.listen(path, () => {
+ hero.log.info({ type: "starting-server", path });
});
};