From addd54fefd062382b65efe33d9bacb0ee3b80182 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Sat, 20 Mar 2021 16:22:59 -0600 Subject: [PATCH] Switched nodemon to foreverjs to hopefully enable restarting internally and fix runtime errors --- Dockerfile | 3 ++- backend/app.js | 9 +-------- backend/entrypoint.sh | 2 +- backend/package.json | 1 - 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7414477..a17794b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,7 @@ RUN apk add --no-cache \ WORKDIR /app COPY --chown=$UID:$GID [ "backend/package.json", "backend/package-lock.json", "/app/" ] +RUN npm install forever -g RUN npm install && chown -R $UID:$GID ./ COPY --chown=$UID:$GID --from=frontend [ "/build/backend/public/", "/app/public/" ] @@ -42,4 +43,4 @@ COPY --chown=$UID:$GID [ "/backend/", "/app/" ] EXPOSE 17442 ENTRYPOINT [ "/app/entrypoint.sh" ] -CMD [ "nodemon", "app.js" ] +CMD [ "forever", "app.js" ] diff --git a/backend/app.js b/backend/app.js index f62d86c..c5e2d11 100644 --- a/backend/app.js +++ b/backend/app.js @@ -335,18 +335,11 @@ async function startServer() { } async function restartServer(is_update = false) { - const restartProcess = () => { - spawn('node', ['app.js'], { - detached: true, - stdio: 'inherit' - }).unref() - process.exit() - } - logger.info(`${is_update ? 'Update complete! ' : ''}Restarting server...`); // the following line restarts the server through nodemon fs.writeFileSync(`restart${is_update ? '_update' : '_general'}.json`, 'internal use only'); + process.exit(1); } async function updateServer(tag) { diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index d30d4fc..611bcc8 100755 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh set -eu -CMD="nodemon app.js" +CMD="forever app.js" # if the first arg starts with "-" pass it to program if [ "${1#-}" != "$1" ]; then diff --git a/backend/package.json b/backend/package.json index 2f2e21f..a38315d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -4,7 +4,6 @@ "description": "backend for YoutubeDL-Material", "main": "index.js", "scripts": { - "preinstall": "npm i nodemon -g", "test": "echo \"Error: no test specified\" && exit 1", "start": "nodemon app.js" },