@@ -2,6 +2,7 @@ package processes
2
2
3
3
import (
4
4
"fmt"
5
+ "sync"
5
6
6
7
log "github.com/sirupsen/logrus"
7
8
"github.com/spf13/afero"
@@ -80,54 +81,76 @@ func BootstrapEnv(appconf *config.AppConfig) error {
80
81
return err
81
82
}
82
83
83
- //r := action.ActRunnerImpl{}
84
- //err = UpdateCoreConfig(appconf, store, nil, "")
85
- //if err != nil {
86
- // log.WithError(err).Error("Problem updating ssm config")
87
- //}
88
-
84
+ // First install Gateway and API Gateway sequentially
89
85
log .Infof ("Setting Up HTTPD Gateway from Marketplace" )
90
- err = installGateway (store , appconf )
91
- if err != nil {
86
+ if err := installGateway (store , appconf ); err != nil {
92
87
log .WithError (err ).Error ("Error installing HTTPD Gateway" )
93
88
err = store .AddToAudit (application .Bootstrap_Unsuccessful , "test" )
94
89
if err != nil {
95
90
log .WithError (err ).Error ("Problem writing to auditlog" )
96
91
}
97
- return err
92
+ return fmt . Errorf ( "gateway installation failed: %w" , err )
98
93
}
99
94
100
- log .Infof ("Setting Up Health Status Lambda" )
101
- err = installHealthStatusLambda (store , appconf )
102
- if err != nil {
103
- log .WithError (err ).Error ("Error installing Health Status" )
95
+ log .Infof ("Setting Up Basic API Gateway from Marketplace" )
96
+ if err := installBasicAPIGateway (store , appconf ); err != nil {
97
+ log .WithError (err ).Error ("Error installing API Gateway" )
104
98
err = store .AddToAudit (application .Bootstrap_Unsuccessful , "test" )
105
99
if err != nil {
106
100
log .WithError (err ).Error ("Problem writing to auditlog" )
107
101
}
108
- return err
102
+ return fmt . Errorf ( "API gateway installation failed: %w" , err )
109
103
}
110
104
111
- log .Infof ("Setting Up Basic API Gateway from Marketplace" )
112
- err = installBasicAPIGateway (store , appconf )
113
- if err != nil {
114
- log .WithError (err ).Error ("Error installing API Gateway" )
115
- err = store .AddToAudit (application .Bootstrap_Unsuccessful , "test" )
116
- if err != nil {
117
- log .WithError (err ).Error ("Problem writing to auditlog" )
105
+ // Now parallelize the remaining installations
106
+ log .Infof ("Starting parallel installation of remaining components" )
107
+
108
+ var wg sync.WaitGroup
109
+ errChan := make (chan error , 2 ) // Buffer for potential errors from 2 installations
110
+
111
+ // Launch Health Status Lambda installation
112
+ wg .Add (1 )
113
+ go func () {
114
+ defer wg .Done ()
115
+ log .Infof ("Setting Up Health Status Lambda" )
116
+ if err := installHealthStatusLambda (store , appconf ); err != nil {
117
+ log .WithError (err ).Error ("Error installing Health Status" )
118
+ errChan <- fmt .Errorf ("health status lambda installation failed: %w" , err )
118
119
}
119
- return err
120
+ }()
121
+
122
+ // Launch Unity UI installation
123
+ wg .Add (1 )
124
+ go func () {
125
+ defer wg .Done ()
126
+ log .Infof ("Setting Up Unity UI from Marketplace" )
127
+ if err := installUnityUi (store , appconf ); err != nil {
128
+ log .WithError (err ).Error ("Error installing unity-portal" )
129
+ errChan <- fmt .Errorf ("unity UI installation failed: %w" , err )
130
+ }
131
+ }()
132
+
133
+ // Wait for remaining installations to complete
134
+ wg .Wait ()
135
+ close (errChan )
136
+
137
+ // Check for any errors that occurred during parallel installation
138
+ var errors []error
139
+ for err := range errChan {
140
+ errors = append (errors , err )
120
141
}
121
142
122
- log .Infof ("Setting Up Unity UI from Marketplace" )
123
- err = installUnityUi (store , appconf )
124
- if err != nil {
125
- log .WithError (err ).Error ("Error installing unity-portal" )
126
- err = store .AddToAudit (application .Bootstrap_Unsuccessful , "test" )
143
+ if len (errors ) > 0 {
144
+ // Combine all errors into a single error message
145
+ errorMsg := "Multiple installation failures:"
146
+ for _ , err := range errors {
147
+ errorMsg += "\n - " + err .Error ()
148
+ }
149
+ err := store .AddToAudit (application .Bootstrap_Unsuccessful , "test" )
127
150
if err != nil {
128
151
log .WithError (err ).Error ("Problem writing to auditlog" )
129
152
}
130
- return err
153
+ return fmt . Errorf ( errorMsg )
131
154
}
132
155
133
156
err = store .AddToAudit (application .Bootstrap_Successful , "test" )
0 commit comments