diff --git a/.github/workflows/domcloud.yml b/.github/workflows/domcloud.yml index 0700254..e3ddc48 100644 --- a/.github/workflows/domcloud.yml +++ b/.github/workflows/domcloud.yml @@ -15,7 +15,7 @@ jobs: webhook_secret: ${{ secrets.WEBHOOK_SECRET_SGA }} webhook_auth: ${{ secrets.WEBHOOK_AUTH_SGA }} data: >- - {"commands":["git pull","npm i","sudo systemctl restart bridge"]} + {"commands":["git pull","npm i","npm test","sudo systemctl restart bridge"]} - name: Invoke NYC deployment hook uses: distributhor/workflow-webhook@v3 env: @@ -23,7 +23,7 @@ jobs: webhook_secret: ${{ secrets.WEBHOOK_SECRET_NYC }} webhook_auth: ${{ secrets.WEBHOOK_AUTH_NYC }} data: >- - {"commands":["git pull","npm i","sudo systemctl restart bridge"]} + {"commands":["git pull","npm i","npm test","sudo systemctl restart bridge"]} - name: Invoke AMS deployment hook uses: distributhor/workflow-webhook@v3 env: @@ -31,7 +31,7 @@ jobs: webhook_secret: ${{ secrets.WEBHOOK_SECRET_AMS }} webhook_auth: ${{ secrets.WEBHOOK_AUTH_AMS }} data: >- - {"commands":["git pull","npm i","sudo systemctl restart bridge"]} + {"commands":["git pull","npm i","npm test","sudo systemctl restart bridge"]} - name: Invoke TYO deployment hook uses: distributhor/workflow-webhook@v3 env: @@ -39,7 +39,7 @@ jobs: webhook_secret: ${{ secrets.WEBHOOK_SECRET_TYO }} webhook_auth: ${{ secrets.WEBHOOK_AUTH_TYO }} data: >- - {"commands":["git pull","npm i","sudo systemctl restart bridge"]} + {"commands":["git pull","npm i","npm test","sudo systemctl restart bridge"]} - name: Invoke BLR deployment hook uses: distributhor/workflow-webhook@v3 env: @@ -47,7 +47,7 @@ jobs: webhook_secret: ${{ secrets.WEBHOOK_SECRET_BLR }} webhook_auth: ${{ secrets.WEBHOOK_AUTH_BLR }} data: >- - {"commands":["git pull","npm i","sudo systemctl restart bridge"]} + {"commands":["git pull","npm i","npm test","sudo systemctl restart bridge"]} - name: Invoke SAO deployment hook uses: distributhor/workflow-webhook@v3 env: @@ -55,4 +55,4 @@ jobs: webhook_secret: ${{ secrets.WEBHOOK_SECRET_SAO }} webhook_auth: ${{ secrets.WEBHOOK_AUTH_SAO }} data: >- - {"commands":["git pull","npm i","sudo systemctl restart bridge"]} + {"commands":["git pull","npm i","npm test","sudo systemctl restart bridge"]} diff --git a/app.js b/app.js index 9294c2c..0b4a0ab 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,20 @@ +const startTime = Date.now(); import { dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = dirname(fileURLToPath(import.meta.url)); process.chdir(__dirname); -import './src/index.js'; \ No newline at end of file +import app from './src/index.js'; + +const port = process.env.PORT ? parseInt(process.env.PORT) : 2223; +const server = app.listen(port, function () { + console.log(`Start time takes ` + (Date.now() - startTime) / 1000 + ` s`) + console.log(`Listening on ${port}`); +}) +server.on('close', () => { + console.log(`Server closing`); + setTimeout(() => { + console.log(`Server force closing`); + process.exit(0); + }, 2000).unref(); +}) diff --git a/package.json b/package.json index ab4848a..7d04a2e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "scripts": { "update-binaries": "node ./src/binaries/update.js", "build": "sh ./tools-init.sh", - "start": "node app.js" + "start": "node app.js", + "test": "node src" }, "keywords": [ "runner" diff --git a/src/index.js b/src/index.js index 6d82f5f..739b503 100644 --- a/src/index.js +++ b/src/index.js @@ -15,7 +15,6 @@ import virtualmin from './controllers/virtualmin.js'; import docker from './controllers/docker.js'; import unit from './controllers/unit.js'; -const startTime = Date.now(); dotenv.config(); initUtils(); @@ -48,16 +47,6 @@ app.use(function (err, req, res, next) { res.json(err); } }); -const port = process.env.PORT ? parseInt(process.env.PORT) : 2223; -const server = app.listen(port, function () { - console.log(`Start time takes ` + (Date.now() - startTime) / 1000 + ` s`) - console.log(`Listening on ${port}`); -}) -server.on('close', () => { - console.log(`Server closing`); - setTimeout(() => { - console.log(`Server force closing`); - process.exit(0); - }, 2000).unref(); -}) + +export default app;