mirror of https://github.com/mthenw/frontail.git
commit
3b1b976c87
7
index.js
7
index.js
|
@ -91,7 +91,12 @@ if (program.daemonize) {
|
|||
/**
|
||||
* When connected send starting data
|
||||
*/
|
||||
var tailer = tail(program.args, {buffer: program.number});
|
||||
var sshOptions = {
|
||||
remoteHost: program.remoteHost,
|
||||
remoteUser: program.remoteUser,
|
||||
remotePort: program.remotePort
|
||||
};
|
||||
var tailer = tail(program.args, {buffer: program.number, sshOptions:sshOptions});
|
||||
var filesSocket = io.of('/' + filesNamespace).on('connection', function (socket) {
|
||||
socket.emit('options:lines', program.lines);
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ var program = require('commander');
|
|||
program
|
||||
.version(require('../package.json').version)
|
||||
.usage('[options] [file ...]')
|
||||
.option('--remote-host <remote_host>', 'setting the remote host for a tail over ssh ( e.g: 192.168.0.2 )', String,
|
||||
null)
|
||||
.option('--remote-user <remote_user>', 'setting the remote user for a tail over ssh, default: root', String, 'root')
|
||||
.option('--remote-port <remote_port>', 'setting the remote port for a tail over ssh, default 22', Number, 22)
|
||||
.option('-h, --host <host>', 'listening host, default 0.0.0.0', String, '0.0.0.0')
|
||||
.option('-p, --port <port>', 'listening port, default 9001', Number, 9001)
|
||||
.option('-n, --number <number>', 'starting lines number, default 10', Number, 10)
|
||||
|
|
15
lib/tail.js
15
lib/tail.js
|
@ -10,8 +10,21 @@ var Tail = function (path, options) {
|
|||
|
||||
options = options || {buffer: 0};
|
||||
this._buffer = new CBuffer(options.buffer);
|
||||
var tail;
|
||||
|
||||
var tail = spawn('tail', ['-n', options.buffer, '-F', path]);
|
||||
if (options && options.sshOptions && options.sshOptions.remoteHost) {
|
||||
var args = [options.sshOptions.remoteUser + '@' + options.sshOptions.remoteHost, '-p',
|
||||
options.sshOptions.remotePort, 'tail -f ' + path];
|
||||
tail = spawn('ssh', args);
|
||||
} else {
|
||||
tail = spawn('tail', ['-n', options.buffer, '-F', path]);
|
||||
}
|
||||
|
||||
tail.stderr.on('data', function (data) {
|
||||
//if there is any error then display it in the console and then kill the tail.
|
||||
console.error(data.toString());
|
||||
process.exit();
|
||||
});
|
||||
|
||||
tail.stdout.on('data', function (data) {
|
||||
var lines = data.toString('utf-8').split('\n');
|
||||
|
|
|
@ -31,7 +31,7 @@ describe('connectBuilder', function () {
|
|||
.expect(200, 'secret!', done);
|
||||
});
|
||||
|
||||
it('should build app that setup session', function (done) {
|
||||
it('should build app that setup session', function (done) {
|
||||
var app = connectBuilder().session('secret', 'sessionkey').build();
|
||||
app.use(function (req, res) {
|
||||
res.end();
|
||||
|
|
Loading…
Reference in New Issue