UNPKG

595 BJavaScriptView Raw
1'use strict';
2var os = require('os');
3var counter = 0;
4
5exports.increment = function() {
6 counter++;
7};
8
9function dump() {
10 if (counter > 0) {
11 var host = os.hostname();
12 var noop = function() {};
13 // Hail mary before the process exits
14 require('child_process').exec('curl -X POST ' +
15 '-H "Content-Type: application/json" ' +
16 '-d \'{"amount": ' + counter + ', "hostname": "' + host + '"}\' ' +
17 'http://stats-chindley.itos.redhat.com/api/stats &', noop);
18 }
19}
20process.on('exit', dump);
21process.on('SIGINT', process.exit);