mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-03-23 04:25:24 +00:00
Add a containerId request parameter for journal-logs api endpoint, and pass it along to journalctl process options.
Change-Type: minor Signed-off-by: Ivan <ivanign04.alt@gmail.com>
This commit is contained in:
parent
0df6b225ff
commit
b5772740ae
@ -471,8 +471,16 @@ export function createV2Api(router: Router, applications: ApplicationManager) {
|
||||
const count = checkInt(req.body.count, { positive: true }) || undefined;
|
||||
const unit = req.body.unit;
|
||||
const format = req.body.format || 'short';
|
||||
const containerId = req.body.containerId;
|
||||
|
||||
const journald = spawnJournalctl({ all, follow, count, unit, format });
|
||||
const journald = spawnJournalctl({
|
||||
all,
|
||||
follow,
|
||||
count,
|
||||
unit,
|
||||
format,
|
||||
containerId,
|
||||
});
|
||||
res.status(200);
|
||||
journald.stdout.pipe(res);
|
||||
res.on('close', () => {
|
||||
|
@ -8,6 +8,7 @@ export function spawnJournalctl(opts: {
|
||||
follow: boolean;
|
||||
count?: number;
|
||||
unit?: string;
|
||||
containerId?: string;
|
||||
format: string;
|
||||
}): ChildProcess {
|
||||
const args = [
|
||||
@ -25,6 +26,10 @@ export function spawnJournalctl(opts: {
|
||||
args.push('-u');
|
||||
args.push(opts.unit);
|
||||
}
|
||||
if (opts.containerId != null) {
|
||||
args.push('-t');
|
||||
args.push(opts.containerId);
|
||||
}
|
||||
if (opts.count != null) {
|
||||
args.push('-n');
|
||||
args.push(opts.count.toString());
|
||||
|
Loading…
x
Reference in New Issue
Block a user