Hello Mark,
Mark Reynolds [2018-03-07 10:05 -0500]:
[1] The first one appears to be a permissions issue. So I am trying
to
watch a file that the Cockpit user does have immediate permissions to,
I suppose you mean does *not* have permissions to?
var logfile =
cockpit.file("/var/log/dirsrv/slapd-localhost/errors");
//var logfile = cockpit.file("/tmp/errors");
If you need this to run with root privs, use
cockpit.file("/path", { superuser: "require" })
or maybe "try" instead of "require", depending on how you want to
handle errors
for non-root users. See the cockpit.file options in
http://cockpit-project.org/guide/latest/cockpit-file.html
[2] What I want to do is the equivalent of "tailing" a log
file, and I
would like to use Cockpit's file watching functionality to do this.
However, when the log file changes the entire file content is returned.
Our log files can grow up to 100mb. Is there a way to only return the
last N lines of a file when it changes without loading the entire
content into memory?
We don't have seek in the API, so for that I'd recommend to only use the file
watching and using cockpit.spawn to run `tail /log/file` instead.
Martin