Add Restarting
parent
7ff8a06ecd
commit
b661e5511f
12
index.js
12
index.js
|
@ -1,6 +1,6 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
|
const { exec } = require('child_process');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const {checkKeyMatch,checkFileMatch} = require("./lib/validation")
|
const {checkKeyMatch,checkFileMatch} = require("./lib/validation")
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
|
@ -159,7 +159,15 @@ function startServer(port) {
|
||||||
fs.watch(jsonPath, (event, filename) => {
|
fs.watch(jsonPath, (event, filename) => {
|
||||||
if (event === 'change') {
|
if (event === 'change') {
|
||||||
console.log('Endpoints file changed. Restarting server...');
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
@HOST = http://localhost:3000
|
@HOST = http://lhdn.kollect.biz:3000
|
||||||
|
@LOCAL = http://localhost:3000
|
||||||
|
|
||||||
###
|
###
|
||||||
POST {{HOST}}/api/v1/student
|
POST {{HOST}}/api/v1/student
|
||||||
|
@ -92,3 +93,10 @@ Content-Type: application/json
|
||||||
|
|
||||||
GET {{HOST}}/api/v1/getlhdn
|
GET {{HOST}}/api/v1/getlhdn
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
|
||||||
|
GET {{LOCAL}}/api/v1/getlhdn6
|
||||||
|
Content-Type: application/json
|
Loading…
Reference in New Issue