initial
This commit is contained in:
27
unix-socket.mjs
Normal file
27
unix-socket.mjs
Normal file
@@ -0,0 +1,27 @@
|
||||
import fs from 'node:fs';
|
||||
|
||||
export class Unix_Socket {
|
||||
constructor(path) {
|
||||
Object.assign(this, { path });
|
||||
}
|
||||
|
||||
get connect_options() {
|
||||
const { path } = this;
|
||||
return { path };
|
||||
}
|
||||
|
||||
listen(server, on_listening) {
|
||||
const { path } = this;
|
||||
if (fs.existsSync(path)) {
|
||||
fs.unlinkSync(path);
|
||||
}
|
||||
|
||||
server.listen(path, () => {
|
||||
fs.chmodSync(path, 0o666);
|
||||
on_listening?.();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user