Add Restarting

main
Kalam Azad 2024-03-12 13:25:53 +08:00
parent 7ff8a06ecd
commit b661e5511f
2 changed files with 19 additions and 3 deletions

View File

@ -1,6 +1,6 @@
const express = require('express');
const multer = require('multer');
const { exec } = require('child_process');
const path = require('path');
const {checkKeyMatch,checkFileMatch} = require("./lib/validation")
const bodyParser = require('body-parser');
@ -159,7 +159,15 @@ function startServer(port) {
fs.watch(jsonPath, (event, filename) => {
if (event === 'change') {
console.log('Endpoints file changed. Restarting server...');
startServer(port);
exec('pm2 restart engine', (error, stdout, stderr) => {
if (error) {
console.error(`Error restarting application: ${error}`);
return;
}
console.log(`Application restarted: ${stdout}`);
startServer(port);
});
}
});

View File

@ -1,4 +1,5 @@
@HOST = http://localhost:3000
@HOST = http://lhdn.kollect.biz:3000
@LOCAL = http://localhost:3000
###
POST {{HOST}}/api/v1/student
@ -91,4 +92,11 @@ Content-Type: application/json
GET {{HOST}}/api/v1/getlhdn
Content-Type: application/json
###
GET {{LOCAL}}/api/v1/getlhdn6
Content-Type: application/json