-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
36 lines (26 loc) · 766 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Include Express
var express = require('express');
var cluster = require('cluster');
var config = require('./config');
// Create a new Express application
var app = express();
// Add a basic route – index page
app.get('/', function (req, res) {
res.send({
message: 'Hello from Worker ' + cluster.worker.id,
port: config.get('port'),
salt: config.get('salt'),
name: config.get('name')
});
});
app.get('/update', function (req, res) {
// const value = req.query.value || 8000;
// const key = req.query.key || 'port';
Object.keys(req.query).forEach((key) => {
process.send({ cmd: 'nconf', key: key, value: req.query[key] });
});
res.send({
message: 'Done update ' + cluster.worker.id,
});
});
module.exports = app;