Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Conversation

@WeiZhang555
Copy link
Contributor

Do not call os.Exit directly in codes, but call "return cli.NewExitError"
instead, so that after the program terminated, glog can flush and no
logs will be lost.

Signed-off-by: Zhang Wei zhangwei555@huawei.com

Do not call os.Exit directly in codes, but call "return cli.NewExitError"
instead, so that after the program terminated, glog can flush and no
logs will be lost.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
@WeiZhang555
Copy link
Contributor Author

The reason that this commit works is that in https://github.com/hyperhq/runv/blob/master/main.go#L144-L148 , there is a glog.Flush() to flush all the logs after the APP exits, but if we call os.Exit in middle directly, there's no way to flush all the logs, hence cached logs would be lost.
With this modification, glog.Flush will always be called when program exits normally (except panic), and we could get all logs for debugging.

@laijs laijs merged commit f67692f into hyperhq:master Jun 22, 2017
@WeiZhang555 WeiZhang555 deleted the guarantee-logs branch June 22, 2017 02:31
jimoosciuc pushed a commit to jimoosciuc/runv that referenced this pull request May 26, 2020
Don't call os.Exit explicitly to avoid lost of logs
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants