1 | 'use strict';
|
2 | var os = require('os');
|
3 | var counter = 0;
|
4 |
|
5 | exports.increment = function() {
|
6 | counter++;
|
7 | };
|
8 |
|
9 | function dump() {
|
10 | if (counter > 0) {
|
11 | var host = os.hostname();
|
12 | var noop = function() {};
|
13 |
|
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 | }
|
20 | process.on('exit', dump);
|
21 | process.on('SIGINT', process.exit);
|