Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #61 from till/t/wrapper
Browse files Browse the repository at this point in the history
Enhancement: bootstrap config and start statsd
  • Loading branch information
bryanmikaelian authored Feb 10, 2017
2 parents 2d68246 + 1633c19 commit f304455
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,21 @@ None

Please use this [branch](https://github.com/librato/statsd-librato-backend/tree/branch-0.1.x).

## Docker

You may use `bin/statsd-librato` to easily bootstrap the daemon inside
a container.

Invoking this via `CMD` or `ENTRYPOINT` will create a simple
configuration and run the statsd daemon with this backend enabled,
listening on `8125`.

The following environment variables are available to customize:

- `LIBRATO_EMAIL`
- `LIBRATO_TOKEN`
- `LIBRATO_SOURCE`

## Development

- [Librato Backend](https://github.com/librato/statsd-librato-backend)
Expand Down
31 changes: 31 additions & 0 deletions bin/statsd-librato
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env node
var fs = require('fs'),
rootPath = require('path').resolve(__dirname, './../../..');

if (!fs.existsSync(rootPath + '/stats.js')) {
console.error('This should run as a dependency inside etsy/statsd');
if (process.env.DEBUG) {
console.log('rootPath: ' + rootPath);
console.log('__dirname: ' + __dirname);
}
process.exit(1);
}

var configPath = rootPath + '/config.js';

if (!fs.existsSync(configPath)) {
var configFile = '';
configFile += '{' + "\n";
configFile += " librato: {\n";
configFile += " email: process.env.LIBRATO_EMAIL || 'default',\n";
configFile += " token: process.env.LIBRATO_TOKEN || 'token',\n";
configFile += " source: process.env.LIBRATRO_SOURCE || 'env'\n";
configFile += ' },' + "\n";
configFile += " backends: [\"statsd-librato-backend\"],\n";
configFile += " port: 8125\n";
configFile += '}';

fs.writeFileSync(configPath, configFile, 'utf-8');
}

require(rootPath + '/bin/statsd');
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
"main": "lib/librato.js",
"scripts": {
"test": "nodeunit test"
},
"bin": {
"statsd-librato": "./bin/statsd-librato"
}
}

0 comments on commit f304455

Please sign in to comment.