@@ -23,6 +23,7 @@ import (
2323 "io/ioutil"
2424 "net/http"
2525 "os"
26+ "os/exec"
2627 "os/user"
2728 "strings"
2829 "time"
@@ -128,8 +129,6 @@ func initialIntegrationServerConfig() error {
128129 }
129130 }
130131
131-
132-
133132 log .Printf ("Initial configuration of integration server complete" )
134133
135134 log .Println ("Discovering override ports" )
@@ -292,8 +291,8 @@ func addOpenTracingToServerConf(serverconfContent []byte) ([]byte, error) {
292291
293292 } else {
294293 serverconfMap ["UserExits" ] = map [string ]string {
295- "activeUserExitList" : "ACEOpenTracingUserExit" ,
296- "userExitPath" : "/opt/ACEOpenTracing" ,
294+ "activeUserExitList" : "ACEOpenTracingUserExit" ,
295+ "userExitPath" : "/opt/ACEOpenTracing" ,
297296 }
298297 }
299298
@@ -329,7 +328,7 @@ func getConfigurationFromContentServer() error {
329328 }
330329
331330 token := os .Getenv ("ACE_CONTENT_SERVER_TOKEN" )
332- if token == "" && defaultContentServer == "true" {
331+ if token == "" && defaultContentServer == "true" {
333332 log .Errorf ("No content server token available but a url is defined" )
334333 return errors .New ("No content server token available but a url is defined" )
335334 }
@@ -375,7 +374,7 @@ func getConfigurationFromContentServer() error {
375374 contentServerKey := os .Getenv ("CONTENT_SERVER_KEY" )
376375 cert , err := tls .LoadX509KeyPair (contentServerCert , contentServerKey )
377376 if err != nil {
378- if ( contentServerCert != "" && contentServerKey != "" ) {
377+ if contentServerCert != "" && contentServerKey != "" {
379378 log .Errorf ("Error reading Certificates: %s" , err )
380379 return errors .New ("Error reading Certificates" )
381380 }
@@ -386,9 +385,9 @@ func getConfigurationFromContentServer() error {
386385 client := & http.Client {
387386 Transport : & http.Transport {
388387 TLSClientConfig : & tls.Config {
389- RootCAs : caCertPool ,
388+ RootCAs : caCertPool ,
390389 Certificates : []tls.Certificate {cert },
391- ServerName : serverName ,
390+ ServerName : serverName ,
392391 },
393392 },
394393 }
@@ -459,11 +458,11 @@ func startIntegrationServer() command.BackgroundCmd {
459458 return returnErr
460459 }
461460
462- defaultAppName := os .Getenv ("ACE_DEFAULT_APPLICATION_NAME" )
463- if defaultAppName == "" {
464- log .Printf ("No default application name supplied. Using the integration server name instead." )
465- defaultAppName = serverName
466- }
461+ defaultAppName := os .Getenv ("ACE_DEFAULT_APPLICATION_NAME" )
462+ if defaultAppName == "" {
463+ log .Printf ("No default application name supplied. Using the integration server name instead." )
464+ defaultAppName = serverName
465+ }
467466
468467 if qmgr .UseQueueManager () {
469468 qmgrName , err := name .GetQueueManagerName ()
@@ -513,32 +512,56 @@ func stopIntegrationServer(integrationServerProcess command.BackgroundCmd) {
513512}
514513
515514func createWorkDir () error {
516- log .Printf ("Checking if work dir is already initialized" )
517- f , err := os .Open ("/home/aceuser/ace-server" )
518- if err != nil {
519- log .Printf ("Error reading /home/aceuser/ace-server" )
520- return err
521- }
522-
523- log .Printf ("Checking for contents in the work dir" )
524- _ , err = f .Readdirnames (1 )
525- if err != nil {
526- log .Printf ("Work dir is not yet initialized - initializing now in /home/aceuser/ace-server" )
527-
528- if qmgr .UseQueueManager () {
529- _ , _ , err := command .RunAsUser ("mqm" , "/opt/ibm/ace-11/server/bin/mqsicreateworkdir" , "/home/aceuser/ace-server" )
530- if err != nil {
531- log .Printf ("Error reading initializing work dir" )
532- return err
533- }
534- } else {
535- _ , _ , err := command .RunAsUser ("aceuser" , "/opt/ibm/ace-11/server/bin/mqsicreateworkdir" , "/home/aceuser/ace-server" )
536- if err != nil {
537- log .Printf ("Error reading initializing work dir" )
538- return err
539- }
540- }
541- }
542- log .Printf ("Work dir initialization complete" )
543- return nil
515+ log .Printf ("Checking if work dir is already initialized" )
516+ f , err := os .Open ("/home/aceuser/ace-server" )
517+ if err != nil {
518+ log .Printf ("Error reading /home/aceuser/ace-server" )
519+ return err
520+ }
521+
522+ log .Printf ("Checking for contents in the work dir" )
523+ _ , err = f .Readdirnames (1 )
524+ if err != nil {
525+ log .Printf ("Work dir is not yet initialized - initializing now in /home/aceuser/ace-server" )
526+
527+ if qmgr .UseQueueManager () {
528+ _ , _ , err := command .RunAsUser ("mqm" , "/opt/ibm/ace-11/server/bin/mqsicreateworkdir" , "/home/aceuser/ace-server" )
529+ if err != nil {
530+ log .Printf ("Error reading initializing work dir" )
531+ return err
532+ }
533+ } else {
534+ _ , _ , err := command .RunAsUser ("aceuser" , "/opt/ibm/ace-11/server/bin/mqsicreateworkdir" , "/home/aceuser/ace-server" )
535+ if err != nil {
536+ log .Printf ("Error reading initializing work dir" )
537+ return err
538+ }
539+ }
540+ }
541+ log .Printf ("Work dir initialization complete" )
542+ return nil
543+ }
544+
545+ func checkLogs () error {
546+ log .Printf ("Contents of log directory" )
547+ system ("ls" , "-l" , "/home/aceuser/ace-server/config/common/log" )
548+
549+ if os .Getenv ("MQSI_PREVENT_CONTAINER_SHUTDOWN" ) == "true" {
550+ log .Printf ("MQSI_PREVENT_CONTAINER_SHUTDOWN set to blocking container shutdown to enable log copy out" )
551+ log .Printf ("Once all logs have been copied out please kill container" )
552+ select {}
553+ }
554+
555+ log .Printf ("If you want to stop the container shutting down to enable retrieval of these files please set the environment variable \" MQSI_PREVENT_CONTAINER_SHUTDOWN=true\" " )
556+ log .Printf ("If you are running under kubernetes you will also need to disable the livenessProbe" )
557+ log .Printf ("Log checking complete" )
558+ return nil
559+ }
560+
561+ func system (cmd string , arg ... string ) {
562+ out , err := exec .Command (cmd , arg ... ).Output ()
563+ if err != nil {
564+ log .Printf (err .Error ())
565+ }
566+ log .Printf (string (out ))
544567}
0 commit comments