Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tools): fabric AIO image log access in CI #643 #644

Merged
merged 1 commit into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
Logger,
LogLevelDesc,
LoggerProvider,
Bools,
} from "@hyperledger/cactus-common";

/*
Expand All @@ -34,6 +35,7 @@ export interface IFabricTestLedgerV1ConstructorOptions {
imageName?: string;
envVars?: Map<string, string>;
logLevel?: LogLevelDesc;
emitContainerLogs?: boolean;
}

/*
Expand Down Expand Up @@ -70,14 +72,15 @@ export class FabricTestLedgerV1 implements ITestLedger {
public readonly imageVersion: string;
public readonly imageName: string;
public readonly publishAllPorts: boolean;
public readonly emitContainerLogs: boolean;
public readonly envVars: Map<string, string>;

private readonly log: Logger;

private container: Container | undefined;
private containerId: string | undefined;

public get className() {
public get className(): string {
return FabricTestLedgerV1.CLASS_NAME;
}

Expand All @@ -92,6 +95,9 @@ export class FabricTestLedgerV1 implements ITestLedger {
this.imageVersion = options.imageVersion || DEFAULT_OPTS.imageVersion;
this.imageName = options.imageName || DEFAULT_OPTS.imageName;
this.publishAllPorts = options.publishAllPorts;
this.emitContainerLogs = Bools.isBooleanStrict(options.emitContainerLogs)
? (options.emitContainerLogs as boolean)
: true;
this.envVars = options.envVars || DEFAULT_OPTS.envVars;

if (compareVersions.compare(this.getFabricVersion(), "1.4", "<"))
Expand Down Expand Up @@ -420,6 +426,16 @@ export class FabricTestLedgerV1 implements ITestLedger {
eventEmitter.once("start", async (container: Container) => {
this.container = container;
this.containerId = container.id;

if (this.emitContainerLogs) {
const logOptions = { follow: true, stderr: true, stdout: true };
const logStream = await container.logs(logOptions);
logStream.on("data", (data: Buffer) => {
const fnTag = `[${this.getContainerImageName()}]`;
this.log.debug(`${fnTag} %o`, data.toString("utf-8"));
});
}

try {
await this.waitForHealthCheck();
resolve(container);
Expand Down
22 changes: 14 additions & 8 deletions tools/docker/fabric-all-in-one/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,34 @@
logfile = /var/log/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = info
loglevel = debug

[program:sshd]
command=/usr/sbin/sshd -D
command=/usr/sbin/sshd -D -dd
autostart=true
autorestart=true
stderr_logfile=/var/log/sshd.err.log
stdout_logfile=/var/log/sshd.out.log
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

[program:dockerd]
command=dockerd-entrypoint.sh
autostart=true
autorestart=true
stderr_logfile=/var/log/dockerd.err.log
stdout_logfile=/var/log/dockerd.out.log
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

[program:fabric-network]
command=/run-fabric-network.sh
autostart=true
autorestart=unexpected
stderr_logfile=/var/log/fabric-network.err.log
stdout_logfile=/var/log/fabric-network.out.log
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

[inet_http_server]
port = 0.0.0.0:9001
Expand Down