]>
git.r.bdr.sh - rbdr/monitorcito/blob - bin/monitorcito
2d41152cf9cf1f4bcb4c859d825832d2a4ea3ce4
3 const Monitorcito
= require('..');
4 const Http
= require('http');
5 const { debuglog
} = require('util');
9 kUnsetServicesError: 'Please specify comma separated services in MONITORCITO_SERVICES env variable',
12 log: debuglog('monitorcito'),
16 internals
.log('Validating arguments');
17 if (!process
.env
.MONITORCITO_SERVICES
) {
18 throw new Error(internals
.kUnsetServicesError
);
21 internals
.arguments
= process
.env
.MONITORCITO_SERVICES
.split(',')
22 internals
.log(`Arguments are ${internals.arguments}`);
27 internals
.log('Setting up the server');
28 const server
= Http
.createServer(async (request
, response
) => {
30 internals
.log('Incoming request');
31 const responseBody
= JSON
.stringify(await
Monitorcito(internals
.arguments
));
32 internals
.log(`Responding with ${responseBody}`);
34 response
.writeHead(200, { 'Content-Type': 'application/json' });
35 response
.write(responseBody
);
38 const port
= Number(process
.env
.MONITORCITO_PORT
) || 1991;
40 internals
.log(`Listening on port ${port}`);
45 internals
.prepareArguments();
46 internals
.startServer();