Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 50 lines (40 sloc) 1.158 kb
#!/usr/bin/env node
"use strict";
var log = require("leg")(process.stdout),
Tremor = require("tremor"),
packageInfo = require("./package.json"),
request = require("request");
if (process.argv.length !== 4) {
console.warn("Usage: tremor-elastic <elasticsearch url> <glob>");
process.exit(1);
}
var elasticSearch = process.argv[2],
glob = process.argv[3];
var tremor = new Tremor({glob: glob});
tremor.on("following", function(o) {
log.info("following file", {name: o.name, file: o.file});
});
tremor.on("data", function(o) {
request({method: "POST", uri: elasticSearch, json: o}, function(err, res, data) {
if (err) {
// disabled for now
//return log.warn("couldn't submit entry", {err: err, input: o});
return;
}
if (res.statusCode !== 201) {
// disabled for now
//return log.warn("invalid response from elasticsearch", {code: res.statusCode, input: o, data: data});
return;
}
});
});
log.info("successfully started", {
package: {
name: packageInfo.name,
version: packageInfo.version,
},
config: {
elasticSearch: elasticSearch,
glob: glob,
},
});
Jump to Line
Something went wrong with that request. Please try again.