Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config file #113

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down Expand Up @@ -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]

Expand All @@ -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

Expand All @@ -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/).
Expand Down
4 changes: 4 additions & 0 deletions cli/rtail-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

'use strict'

const fs = require('fs')
const dgram = require('dgram')
const split = require('split')
const chrono = require('chrono-node')
Expand Down Expand Up @@ -77,6 +78,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

/*!
Expand Down
4 changes: 4 additions & 0 deletions cli/rtail-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

'use strict'

const fs = require('fs')
const dgram = require('dgram')
const app = require('express')()
const serve = require('express').static
Expand Down Expand Up @@ -67,6 +68,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

/*!
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down