-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_node.go
32 lines (26 loc) · 960 Bytes
/
start_node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package platform_aws_ecs
import (
"context"
"github.com/awlsring/texit/internal/pkg/domain/node"
"github.com/awlsring/texit/internal/pkg/logger"
platform_aws "github.com/awlsring/texit/internal/pkg/platform/aws"
"github.com/aws/aws-sdk-go-v2/service/ecs"
)
func (g *PlatformAwsEcsGateway) StartNode(ctx context.Context, node *node.Node) error {
log := logger.FromContext(ctx)
log.Debug().Msg("Starting ECS node")
log.Debug().Msgf("Getting ecs client for location %s", node.Location.String())
ecsClient, err := platform_aws.GetClientForLocation(ctx, ecs.NewFromConfig, g.ecsCache, node.Location, g.Creds)
if err != nil {
log.Error().Err(err).Msg("Failed to get ECS client")
return err
}
log.Debug().Msg("Scaling service to 1 replica")
err = scaleService(ctx, ecsClient, node.Identifier, activeCount)
if err != nil {
log.Error().Err(err).Msg("Failed to scale service")
return err
}
log.Debug().Msg("ECS node started")
return nil
}