serverRoot support + health checks
This commit is contained in:
parent
7683e50450
commit
545ebe504b
17
server.js
17
server.js
|
@ -24,13 +24,26 @@ var ptserver = express()
|
||||||
var PORT = process.env.server_port || 8089
|
var PORT = process.env.server_port || 8089
|
||||||
|
|
||||||
// Setup our PTServer
|
// Setup our PTServer
|
||||||
|
|
||||||
|
ptserver.get('/health', (req, res) => {
|
||||||
|
res.setHeader('Content-Type', 'application/json')
|
||||||
|
let connectedUsers = Object.keys(ptserver_io.sockets.connected).length
|
||||||
|
let load = 'low'
|
||||||
|
if (connectedUsers > 25) {
|
||||||
|
load = 'medium'
|
||||||
|
}
|
||||||
|
if (connectedUsers > 50) {
|
||||||
|
load = 'high'
|
||||||
|
}
|
||||||
|
return res.send(JSON.stringify({ load })).end()
|
||||||
|
})
|
||||||
ptserver.get('/', (req, res) => {
|
ptserver.get('/', (req, res) => {
|
||||||
return res.send('You\'ve connected to the SLServer, you\'re probably looking for the webapp.')
|
return res.send('You\'ve connected to the SLServer, you\'re probably looking for the webapp.')
|
||||||
})
|
})
|
||||||
|
|
||||||
// Merge everything together
|
// Merge everything together
|
||||||
|
|
||||||
let serverRoot = '/' || settings.serverRoot
|
let serverRoot = settings.serverRoot || '/'
|
||||||
|
console.log('Setting up with serverRoot of', serverRoot)
|
||||||
root.use(serverRoot, ptserver)
|
root.use(serverRoot, ptserver)
|
||||||
root.get('*', function (req, res) {
|
root.get('*', function (req, res) {
|
||||||
return res.send('You\'ve connected to the SLServer, you\'re probably looking for the webapp.')
|
return res.send('You\'ve connected to the SLServer, you\'re probably looking for the webapp.')
|
||||||
|
|
Loading…
Reference in New Issue