From 5463dbc56915e9ab6eecc7ad53d0de317755f249 Mon Sep 17 00:00:00 2001 From: Kostas Bariotis Date: Sat, 19 Mar 2016 12:42:21 +0200 Subject: [PATCH 1/5] add config instraction to yargs --- cli/rtail-client.js | 3 +++ cli/rtail-server.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cli/rtail-client.js b/cli/rtail-client.js index 188e463..c508dd7 100755 --- a/cli/rtail-client.js +++ b/cli/rtail-client.js @@ -77,6 +77,9 @@ let argv = yargs .version(pkg.version, 'version') .alias('version', 'v') .strict() + .config('--config-file', 'Configuration file path', function (configFile) { + return JSON.parse(fs.readFileSync(configFile, 'utf-8')).client + }) .argv /*! diff --git a/cli/rtail-server.js b/cli/rtail-server.js index 29a7c30..4cff428 100755 --- a/cli/rtail-server.js +++ b/cli/rtail-server.js @@ -67,6 +67,9 @@ let argv = yargs .version(pkg.version, 'version') .alias('version', 'v') .strict() + .config('--config-file', 'Configuration file path', function (configFile) { + return JSON.parse(fs.readFileSync(configFile, 'utf-8')).server + }) .argv /*! From 9ea2f81c771f554a94ac0ece6e9eae38854c7d48 Mon Sep 17 00:00:00 2001 From: Kostas Bariotis Date: Sat, 19 Mar 2016 12:42:47 +0200 Subject: [PATCH 2/5] update yargs to support config --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a56e722..31cb436 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "strip-ansi": "^3.0.0", "through2-map": "^2.0.0", "update-notifier": "^0.5.0", - "yargs": "^3.14.0" + "yargs": "^3.32.0" }, "devDependencies": { "angular": "^1.3.15", From 8098707c16d2aafc107b497560d156988b2275d2 Mon Sep 17 00:00:00 2001 From: Kostas Bariotis Date: Sat, 19 Mar 2016 12:43:24 +0200 Subject: [PATCH 3/5] add missing fs require --- cli/rtail-client.js | 1 + cli/rtail-server.js | 1 + 2 files changed, 2 insertions(+) diff --git a/cli/rtail-client.js b/cli/rtail-client.js index c508dd7..e9cab69 100755 --- a/cli/rtail-client.js +++ b/cli/rtail-client.js @@ -9,6 +9,7 @@ 'use strict' +const fs = require('fs') const dgram = require('dgram') const split = require('split') const chrono = require('chrono-node') diff --git a/cli/rtail-server.js b/cli/rtail-server.js index 4cff428..28bb954 100755 --- a/cli/rtail-server.js +++ b/cli/rtail-server.js @@ -9,6 +9,7 @@ 'use strict' +const fs = require('fs') const dgram = require('dgram') const app = require('express')() const serve = require('express').static From 7f2e03d011f185dcbf72a4a405e1b335fcd07e85 Mon Sep 17 00:00:00 2001 From: Kostas Bariotis Date: Sat, 19 Mar 2016 12:45:00 +0200 Subject: [PATCH 4/5] proper config file key --- cli/rtail-client.js | 2 +- cli/rtail-server.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/rtail-client.js b/cli/rtail-client.js index e9cab69..380a1b2 100755 --- a/cli/rtail-client.js +++ b/cli/rtail-client.js @@ -78,7 +78,7 @@ let argv = yargs .version(pkg.version, 'version') .alias('version', 'v') .strict() - .config('--config-file', 'Configuration file path', function (configFile) { + .config('config-file', 'Configuration file path', function (configFile) { return JSON.parse(fs.readFileSync(configFile, 'utf-8')).client }) .argv diff --git a/cli/rtail-server.js b/cli/rtail-server.js index 28bb954..8051449 100755 --- a/cli/rtail-server.js +++ b/cli/rtail-server.js @@ -68,7 +68,7 @@ let argv = yargs .version(pkg.version, 'version') .alias('version', 'v') .strict() - .config('--config-file', 'Configuration file path', function (configFile) { + .config('config-file', 'Configuration file path', function (configFile) { return JSON.parse(fs.readFileSync(configFile, 'utf-8')).server }) .argv From 89d60ff1b381831f0376d03d752a03e70cceeedb Mon Sep 17 00:00:00 2001 From: Kostas Bariotis Date: Sat, 19 Mar 2016 12:53:34 +0200 Subject: [PATCH 5/5] update documentation --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fb2a72a..92bb421 100644 --- a/README.md +++ b/README.md @@ -75,17 +75,19 @@ For fun and debugging: --mute, -m Don't pipe stdin with stdout [boolean] --tty Keeps ansi colors [boolean] [default: true] --parse-date Looks for dates to use as timestamp [boolean] [default: true] + --config-file Pass a configuration file [string] --help Show help [boolean] --version, -v Show version number [boolean] Examples: - server | rtail > server.log localhost + file - server | rtail --id api.domain.com Name the log stream - server | rtail --host example.com Sends to example.com - server | rtail --port 43567 Uses custom port - server | rtail --mute No stdout - server | rtail --no-tty Strips ansi colors - server | rtail --no-date-parse Disable date parsing/stripping + server | rtail > server.log localhost + file + server | rtail --id api.domain.com Name the log stream + server | rtail --host example.com Sends to example.com + server | rtail --port 43567 Uses custom port + server | rtail --mute No stdout + server | rtail --no-tty Strips ansi colors + server | rtail --no-date-parse Disable date parsing/stripping + server | rtail --config-file ~/.rtail Read configuration from file ## `rtail-server(1)` @@ -125,6 +127,7 @@ Open your browser and start tailing logs! --web-host, --wh The listening HTTP hostname [default: "127.0.0.1"] --web-port, --wp The listening HTTP port [default: 8888] --web-version Define web app version to serve [string] + --config-file Pass a configuration file [string] --help, -h Show help [boolean] --version, -v Show version number [boolean] @@ -134,6 +137,7 @@ Open your browser and start tailing logs! rtail-server --web-version stable Always uses latest stable webapp rtail-server --web-version unstable Always uses latest develop webapp rtail-server --web-version 0.1.3 Use webapp v0.1.3 + rtail-server --config-file ~/.rtail Read configuration from file ## UDP Broadcasting @@ -143,6 +147,38 @@ To scale and broadcast on multiple servers, instruct the `rtail` client to strea For the time being, the webapp doesn't have an authentication layer; it assumes that you will run it behind a VPN or reverse proxy, with a simple `Authorization` header check. +# Config file +Both rtail server and client supports configuration file. + +The schema is : +```json +{ + "server": { + "udp-host": "127.0.0.1", + "udp-port": "9999", + "web-host": "127.0.0.1", + "web-port": "8888", + "web-version": "" + }, + "client": { + "host": "127.0.0.1", + "port": "9999", + "id": "127.0.0.1", + "mute": "", + "tty": true, + "parse-date": true + } +} +``` + +CLI arguments will always override the configuration file. + +##Example +Create a file `.rtail` to your home directory with the above contents and make +any changes you want. + + $ rtail-server --config-file ~/.rtail + # How to contribute This project follows the awesome [Vincent Driessen](http://nvie.com/about/) [branching model](http://nvie.com/posts/a-successful-git-branching-model/).