feat: add service log

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2019-12-28 15:06:07 +08:00
parent aed21b2ff6
commit 752e771285
12 changed files with 161 additions and 106 deletions

View File

@@ -3,4 +3,14 @@ import * as common from './common'
export declare namespace service {
export interface ListOpts extends common.query.FilterOpt {
}
export interface LogsOpts {
details?: boolean;
follow?: boolean;
stdout?: boolean;
stderr?: boolean;
since?: number;
until?: number;
timestamps?: boolean;
tail?: number | "all";
}
}

View File

@@ -1,6 +1,7 @@
import * as api from '../utils/api';
import * as opts from '../api/opts';
import * as types from '../api/types';
import * as http from 'http'
export namespace service {
export async function list(filters?: opts.service.ListOpts) {
@@ -15,4 +16,14 @@ export namespace service {
export async function update(id: string, query: { version: number, registryAuthFrom?: string, rollback?: string }, data: any) {
return await api.post<any>(api.getUri(`/services/${id}/update`, query), data)
}
export async function logs(id: string, opts: opts.service.LogsOpts = {}): Promise<http.ServerResponse> {
let data = {
follow: true,
stdout: true,
stderr: true,
tail: 10,
...opts
}
return await api.stream(`/services/${id}/logs`, data);
}
}