Skip to content

Commit

Permalink
fix: start one ingress server per controller (#1655)
Browse files Browse the repository at this point in the history
Fixes #1643

This change will increment the port for each `ingress` and `controller`
being created. One ingress server per controller. The result would look
something like this (keeping the `8892` and `8891` ports respectively)

```bash
info: Starting FTL with 5 controller(s)
info:controller2: Web console available at: http://localhost:8896
info:controller4: Web console available at: http://localhost:8900
info:controller0: Web console available at: http://localhost:8892
info:controller3: Web console available at: http://localhost:8898
info:controller1: Web console available at: http://localhost:8894
info:controller4: HTTP ingress server listening on: http://localhost:8899
info:controller2: HTTP ingress server listening on: http://localhost:8895
info:controller0: HTTP ingress server listening on: http://localhost:8891
info:controller3: HTTP ingress server listening on: http://localhost:8897
info:controller1: HTTP ingress server listening on: http://localhost:8893
```
  • Loading branch information
wesbillman authored Jun 5, 2024
1 parent 8aef214 commit 70b0ebb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/ftl/cmd_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ func (s *serveCmd) Run(ctx context.Context) error {

wg, ctx := errgroup.WithContext(ctx)

bindAllocator, err := bind.NewBindAllocator(s.Bind)
bindAllocator, err := bind.NewBindAllocator(s.IngressBind)
if err != nil {
return err
}

controllerAddresses := make([]*url.URL, 0, s.Controllers)
ingressAddresses := make([]*url.URL, 0, s.Controllers)
for range s.Controllers {
ingressAddresses = append(ingressAddresses, bindAllocator.Next())
controllerAddresses = append(controllerAddresses, bindAllocator.Next())
}

Expand All @@ -102,7 +104,7 @@ func (s *serveCmd) Run(ctx context.Context) error {
config := controller.Config{
CommonConfig: s.CommonConfig,
Bind: controllerAddresses[i],
IngressBind: s.IngressBind,
IngressBind: ingressAddresses[i],
Key: model.NewLocalControllerKey(i),
DSN: dsn,
}
Expand Down
4 changes: 4 additions & 0 deletions examples/go/echo/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 70b0ebb

Please sign in to comment.