commit 5ac439a96cb376c5dde278f974c6c6c4667854a6 Author: n08i40k Date: Fri Apr 10 17:48:16 2026 +0000 feat: initial commit diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..56e2bcb --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +PROBE_PORT=3567 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..41d1af4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:20-alpine + +WORKDIR /app + +COPY probe-server.js /app/probe-server.js + +ENV PORT=19090 +ENV HOST=0.0.0.0 + +EXPOSE 19090 + +CMD ["node", "probe-server.js"] + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..abd4e95 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +services: + probe-server: + build: + context: . + container_name: yc-probe-server + restart: always + environment: + PORT: ${PROBE_PORT:-19090} + HOST: 0.0.0.0 + ports: + - "${PROBE_PORT:-19090}:${PROBE_PORT:-19090}" + diff --git a/probe-server.js b/probe-server.js new file mode 100644 index 0000000..a8746f3 --- /dev/null +++ b/probe-server.js @@ -0,0 +1,26 @@ +'use strict'; + +const net = require('node:net'); + +const PORT = Number(process.env.PORT || 19090); +const HOST = process.env.HOST || '0.0.0.0'; + +if (Number.isNaN(PORT)) { + throw new Error('PORT must be a number'); +} + +const server = net.createServer((socket) => { + socket.setKeepAlive(true, 15000); + + socket.on('data', (buf) => { + const msg = buf.toString('utf8').trim(); + if (msg === 'ping') { + socket.write('pong\n'); + } + }); +}); + +server.listen(PORT, HOST, () => { + console.log(`[probe] listening on ${HOST}:${PORT}`); +}); +