Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including forwardho with all npm packages installed. Try it out:

var forwardho = require("forwardho")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

forwardho v0.0.7

forward log data from a bunch of watched log files over the network with a simple json protocol

Build Status

forwardho

Tails a file. it should work great. it will continue to work even if a file is unlinked rotated or truncated. It is also ok if the path doesnt exist before watching it

Example

if you install globally you will get forwardho as a command it accepts options as arguments or reads them from the most local forwardho.json

gt; forwardho

as a library


var forwardho = require('forwardho'),
client = forwardho({host:'localhost',port:5140,logs:['/var/log/some.log','/var/log/someother.log']});

to shutdown

client.close();
,,,
## install

    npm install -g forwardho

### library argument structure

client = forwardho(options);


- options. supported custom options are

    ```js
    {
      "logs":[],
      "host":"localhost",
      "port":5140,
      "keepAlive":true,
      "keepAliveInterval":10000,
      "reconnectInitialTimeout":100,
      "reconnectMaxInterval":30000,
      "tailOptions":{}
    }

    where tailOptions can be the following  tailfd options. right now tail options are always applied to all logs watched by this client.
    {

    "delimiter":"\n"
    //optional. defaults to newline but can be anything

    }

    // the options object is passed to watchfd as well. With watchfd you may configure

    {

    "timeout": 60*60*1000, //defaults to one hour
    //how long an inactive file descriptor can remain inactive before being cleared

    "timeoutInterval":60*5*1000 //every five minutes
    // how often to check for inactive file descriptors

    }

    //the options object is also passed directly to fs.watch and fs.watchFile so you may configure

    {
    "persistent":true, //defaults to true
    //persistent indicates whether the process should continue to run as long as files are being watched

    "interval":0, //defaults 0
    //interval indicates how often the target should be polled, in milliseconds. (On Linux systems with inotify, interval is ignored.) 
    }
    ```



#### watch file and watch may behave differently on different systems here is the doc for it.

- http://nodejs.org/api/fs.html#fs_fs_writefile_filename_data_encoding_callback
- http://nodejs.org/api/fs.html#fs_fs_watch_filename_options_listener
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free