From 7c573956c1b0d6eb8da80dca665c4ef19b1fb719 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Sat, 6 Apr 2024 14:05:16 +0200 Subject: [PATCH] f --- deploy/npm_server.js | 18 ++++++++++++++++++ deploy/script.sh | 7 +++++++ 2 files changed, 25 insertions(+) create mode 100644 deploy/npm_server.js create mode 100644 deploy/script.sh diff --git a/deploy/npm_server.js b/deploy/npm_server.js new file mode 100644 index 0000000..d077eb8 --- /dev/null +++ b/deploy/npm_server.js @@ -0,0 +1,18 @@ +const express = require('express'); +const { spawn } = require('child_process'); + +const app = express(); + +app.get('/release/pull', (req, res) => { + const deployProcess = spawn('/bin/bash', ['-c', './script.sh'], + { + cwd: process.cwd(), + stdio: "inherit" + } + ); + res.send('Hello World'); +}); + +const server = app.listen(5000, '0.0.0.0', () => { + console.log('Server running'); +}); diff --git a/deploy/script.sh b/deploy/script.sh new file mode 100644 index 0000000..d010ff9 --- /dev/null +++ b/deploy/script.sh @@ -0,0 +1,7 @@ +for i in {1..10} +do + docker compose pull + # docker-compose config + docker compose up -d + sleep 10 +done