Skip to content

Commit

Permalink
Fixed initial lines amount for local:file sources (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
mishankov authored Aug 8, 2022
1 parent d5967d1 commit b4fcb5b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 59 deletions.
66 changes: 12 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"express-rate-limit": "^6.2.0",
"open": "^8.4.0",
"ssh2": "^1.5.0",
"tail-file": "^1.4.15",
"tail": "^2.2.4",
"ws": "^8.4.2"
}
}
8 changes: 4 additions & 4 deletions src/server/models/sources/local.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Tail = require("tail-file");
const Tail = require("tail").Tail;
const { spawn, ChildProcess } = require("child_process");

import type { SourceConfig } from "../config";
Expand All @@ -13,7 +13,7 @@ class LocalFileSource extends Source {
newLineCallback: CallableFunction
) {
super(config, initialLinesAmount, newLineCallback);
this.tail = new Tail(this.config.path, { force: true });
this.tail = new Tail(this.config.path, { nLines: initialLinesAmount });
}

configConnection() {
Expand All @@ -27,11 +27,11 @@ class LocalFileSource extends Source {
}

startReading() {
this.tail.start();
this.tail.watch();
}

closeConnection() {
this.tail.stop();
this.tail.unwatch();
}
}

Expand Down

0 comments on commit b4fcb5b

Please sign in to comment.