About
Need to tail a file on a remote server? ftp-tail should be able to help!
Motivation
To collect the data we needed to build SquadJS, a scripting framework for Squad servers, we found we needed to tail the Squad server's log files. As a result of this, it became a requirement that SquadJS must be installed on the same machine as the Squad server, however, this prevented anyone using rented Squad server instances from using SquadJS. Thus, we endeavoured to make it possible for these logs files to be streamed over the FTP and SFTP servers provided by most hosts - ftp-tail is the outcome of this and we have opened-sourced it for others to benefit from.
Usage
FTP
import { FTPTail } from 'ftp-tail';
(async () => {
const tailer = new FTPTail(
{
ftp: {
host: "xxx.xxx.xxx.xxx",
user: "user",
password: "password",
timeout: 5 * 1000,
encoding: 'utf8'
},
fetchInterval: 0,
log: true
}
);
tailer.on('line', console.log);
await tailer.watch('/SquadGame.log');
await tailer.unwatch();
})();
SFTP
import { SFTPTail } from 'ftp-tail';
(async () => {
const tailer = new SFTPTail(
{
ftp: {
host: "xxx.xxx.xxx.xxx",
username: "user",
password: "password",
},
fetchInterval: 0,
log: true
}
);
tailer.on('line', console.log);
await tailer.watch('/SquadGame.log');
await tailer.unwatch();
})();
Credits
The logic behind ftp-tail was originally proposed, designed and implemented by awn.gg - ftp-tail is an open-sourced re-implementation of their efforts.