mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
Release v1.0.0 🎉
This commit is contained in:
25
lib/services/stats.js
Normal file
25
lib/services/stats.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const config = require('../../conf/config.json');
|
||||
let lastScrape = {};
|
||||
|
||||
if (config.enableStats) {
|
||||
const http = require('http');
|
||||
http
|
||||
.createServer((req, res) => {
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
config,
|
||||
lastScrape
|
||||
})
|
||||
);
|
||||
})
|
||||
.listen(config.statsPort, '127.0.0.1');
|
||||
}
|
||||
|
||||
exports.setLastScrape = (serviceName, numberFound) => {
|
||||
lastScrape[serviceName] = lastScrape[serviceName] || [];
|
||||
lastScrape[serviceName].push({
|
||||
scapeTime: new Date().toString(),
|
||||
numberFound: numberFound
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user