@@ -19,14 +19,16 @@ package main
1919
2020import (
2121 "errors"
22+ "io/ioutil"
2223 "os"
2324
25+ "github.com/ot4i/ace-docker/common/designer"
2426 "github.com/ot4i/ace-docker/internal/command"
2527 "github.com/ot4i/ace-docker/internal/configuration"
28+ iscommandsapi "github.com/ot4i/ace-docker/internal/isCommandsApi"
2629 "github.com/ot4i/ace-docker/internal/metrics"
2730 "github.com/ot4i/ace-docker/internal/name"
2831 "github.com/ot4i/ace-docker/internal/qmgr"
29- "github.com/ot4i/ace-docker/common/designer"
3032)
3133
3234func doMain () error {
@@ -57,6 +59,7 @@ func doMain() error {
5759 }
5860
5961 performShutdown := func () {
62+
6063 metrics .StopMetricsGathering ()
6164
6265 log .Print ("Stopping Integration Server" )
@@ -69,9 +72,41 @@ func doMain() error {
6972
7073 checkLogs ()
7174
75+ iscommandsapi .StopCommandsAPIServer ()
7276 log .Print ("Shutdown complete" )
7377 }
7478
79+ restartIntegrationServer := func () error {
80+ err := ioutil .WriteFile ("/tmp/integration_server_restart.timestamp" , []byte ("" ), 0755 )
81+
82+ if err != nil {
83+ log .Print ("RestartIntegrationServer - Creating restart file failed" )
84+ return err
85+ }
86+
87+ log .Print ("RestartIntegrationServer - Stopping integration server" )
88+ stopIntegrationServer (integrationServerProcess )
89+ log .Println ("RestartIntegrationServer - Starting integration server" )
90+
91+ integrationServerProcess = startIntegrationServer ()
92+ err = integrationServerProcess .ReturnError
93+
94+ if integrationServerProcess .ReturnError == nil {
95+ log .Println ("RestartIntegrationServer - Waiting for integration server" )
96+ err = waitForIntegrationServer ()
97+ }
98+
99+ if err != nil {
100+ logTermination (err )
101+ performShutdown ()
102+ return err
103+ }
104+
105+ log .Println ("RestartIntegrationServer - Integration server is ready" )
106+
107+ return nil
108+ }
109+
75110 // Start signal handler
76111 signalControl := signalHandler (performShutdown )
77112
@@ -120,7 +155,7 @@ func doMain() error {
120155 return err
121156 }
122157
123- // Note: this will do nothing if there are no crs set in the environment
158+ // Note: this will do nothing if there are no crs set in the environment
124159 err = configuration .SetupConfigurationsFiles (log , "/home/aceuser" )
125160 if err != nil {
126161 logTermination (err )
@@ -150,7 +185,7 @@ func doMain() error {
150185 performShutdown ()
151186 return err
152187 }
153-
188+
154189 log .Println ("Starting integration server" )
155190 integrationServerProcess = startIntegrationServer ()
156191 if integrationServerProcess .ReturnError != nil {
@@ -174,6 +209,15 @@ func doMain() error {
174209 log .Println ("Metrics are disabled" )
175210 }
176211
212+ log .Println ("Starting integration server commands API server" )
213+ err = iscommandsapi .StartCommandsAPIServer (log , 7980 , restartIntegrationServer )
214+
215+ if err != nil {
216+ log .Println ("Failed to start isapi server " + err .Error ())
217+ } else {
218+ log .Println ("Integration API started" )
219+ }
220+
177221 // Start reaping zombies from now on.
178222 // Start this here, so that we don't reap any sub-processes created
179223 // by this process (e.g. for crtmqm or strmqm)
0 commit comments