Skip to content
Browse files

add initial application

  • Loading branch information...
0 parents commit f0592d2dff9fb6271e45491a16b960e5db7ca124 @cbrake committed Jan 25, 2013
Showing with 37 additions and 0 deletions.
  1. +37 −0 app.js
37 app.js
@@ -0,0 +1,37 @@
+// example app to get data from a number of systemd-journald-gatewayd instances
+// useage: app.js http://<machine 1>:19531/entries?follow http://<machine 2>:19531/entries?follow ...
+// this is actually a general purpose app that could be used to stream data
+// from any number of URIs
+
+http = require('http')
+
+var setUp = function(uri) {
+ var match = /http:\/\/(.*):/.exec(uri)
+ var host
+ if (match) {
+ host = match[1]
+ } else {
+ console.log('Error parsing: ' + uri)
+ }
+
+ http.get(uri, function(res) {
+ res.setEncoding('utf8')
+ res.on('data', function(chunk) {
+ process.stdout.write(host + ':' + chunk)
+ })
+ }).on('error', function(e) {
+ // console.log("Got Error: " + e.message);
+ }).on('close', function() {
+ //console.log("Connection closed, restarting")
+ // the following is used to break recursion
+ // and blowing the stack
+ setTimeout(setUp, 0, uri)
+ })
+}
+
+process.argv.forEach(function(val, index, array) {
+ if (index >= 2) {
+ setUp(val)
+ }
+})
+

0 comments on commit f0592d2

Please sign in to comment.
Something went wrong with that request. Please try again.