Skip to content

Commit

Permalink
Test before restart
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Jun 16, 2024
1 parent 061b6ce commit c643e7a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/domcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,44 @@ 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:
webhook_url: https://my.domcloud.co/api/githubdeploy
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:
webhook_url: https://my.domcloud.co/api/githubdeploy
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:
webhook_url: https://my.domcloud.co/api/githubdeploy
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:
webhook_url: https://my.domcloud.co/api/githubdeploy
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:
webhook_url: https://my.domcloud.co/api/githubdeploy
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"]}
16 changes: 15 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -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';
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();
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 2 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;

0 comments on commit c643e7a

Please sign in to comment.