To fix web server logs' header missing issue (#424)
* Fix for issue
* Tests case added
* Update main.go
Keep the mirror code ready before web server comes up and would start logging. For this, moved the postInit() function call after checkLogSourceForMirroring("web").
* Updates post review meeting
* Update docker_api_test.go
To fix travis build error
* Comment altered
This commit is contained in:
committed by
GitHub Enterprise
parent
dfa8e1ba41
commit
1f7334e3d1
@@ -211,7 +211,7 @@ func mirrorHTPasswdLogs(ctx context.Context, wg *sync.WaitGroup, name string, fr
|
||||
|
||||
// mirrorWebServerLogs starts a goroutine to mirror the contents of the Liberty web server messages.log
|
||||
func mirrorWebServerLogs(ctx context.Context, wg *sync.WaitGroup, name string, fromStart bool, mf mirrorFunc) (chan error, error) {
|
||||
return mirrorLog(ctx, wg, "/var/mqm/web/installations/Installation1/servers/mqweb/logs/messages.log", false, mf, true)
|
||||
return mirrorLog(ctx, wg, "/var/mqm/web/installations/Installation1/servers/mqweb/logs/messages.log", fromStart, mf, true)
|
||||
}
|
||||
|
||||
func getDebug() bool {
|
||||
|
||||
@@ -165,6 +165,27 @@ func doMain() error {
|
||||
log.Println("One or more invalid value is provided for MQ_LOGGING_CONSOLE_SOURCE. Allowed values are 'qmgr' & 'web' in csv format")
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
defer func() {
|
||||
log.Debug("Waiting for log mirroring to complete")
|
||||
wg.Wait()
|
||||
}()
|
||||
ctx, cancelMirror := context.WithCancel(context.Background())
|
||||
defer func() {
|
||||
log.Debug("Cancel log mirroring")
|
||||
cancelMirror()
|
||||
}()
|
||||
|
||||
//For mirroring web server logs if source variable is set
|
||||
if checkLogSourceForMirroring("web") {
|
||||
// Always log from the end of the web server messages.log, because the log rotation should happen as soon as the web server starts
|
||||
_, err = mirrorWebServerLogs(ctx, &wg, name, false, mf)
|
||||
if err != nil {
|
||||
logTermination(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = postInit(name, keyLabel, defaultP12Truststore)
|
||||
if err != nil {
|
||||
logTermination(err)
|
||||
@@ -205,17 +226,6 @@ func doMain() error {
|
||||
}
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
defer func() {
|
||||
log.Debug("Waiting for log mirroring to complete")
|
||||
wg.Wait()
|
||||
}()
|
||||
ctx, cancelMirror := context.WithCancel(context.Background())
|
||||
defer func() {
|
||||
log.Debug("Cancel log mirroring")
|
||||
cancelMirror()
|
||||
}()
|
||||
|
||||
//For mirroring mq system logs and qm logs, if environment variable is set
|
||||
if checkLogSourceForMirroring("qmgr") {
|
||||
//Mirror MQ system logs
|
||||
@@ -241,17 +251,6 @@ func doMain() error {
|
||||
}
|
||||
}
|
||||
|
||||
//For mirroring web server logs if source variable is set
|
||||
if checkLogSourceForMirroring("web") {
|
||||
// Always log from the start of the web server messages.log, as
|
||||
// Liberty resets it.
|
||||
_, err = mirrorWebServerLogs(ctx, &wg, name, true, mf)
|
||||
if err != nil {
|
||||
logTermination(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = updateCommandLevel()
|
||||
if err != nil {
|
||||
logTermination(err)
|
||||
|
||||
Reference in New Issue
Block a user