From f775f64034ea8c93dfa9a6009991e377cbff43ec Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 14 Jan 2026 15:14:14 +0200 Subject: [PATCH] docker --- Dockerfile | 9 +++++++++ index.js | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3bafd13 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM node:22 + +COPY node_modules index.js package.json yarn.lock . +RUN yarn + +ENTRYPOINT node ./index.js + +LABEL org.opencontainers.image.title="hj-stream-bot" \ + org.opencontainers.image.description="HJ Stream Bot" diff --git a/index.js b/index.js index 5924617..f3f8eb5 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,10 @@ const userBearer = process.env.USER_BEARER; const instance = process.env.INSTANCE; const videoId = process.env.VIDEO_ID; -const globalState = { currentlyLive: false }; +const globalState = { + exit: false, + currentlyLive: false, +}; const headers = (bearer) => ({ accept: '*/*', @@ -55,6 +58,7 @@ const scrobble = ({ title, external_link }) => // }); process.on('SIGINT', () => { + globalState.exit = true; process.exit(); }); @@ -90,7 +94,7 @@ const loop = async () => { } } - setTimeout(loop, 30 * 1000); + if (!globalState.exit) setTimeout(loop, 30 * 1000); }; loop();