Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
satellite/console: optional separate web app server
This change creates the ability to run a server separate from the console web server to serve the front end app. You can run it with `satellite run ui`. Since there are now potentially two servers instead of one, the UI server has the option to act as a reverse proxy to the api server for local development by setting `--console.address` to the console backend address and `--console.backend-reverse-proxy` to the console backend's http url. Also, a feature flag has been implemented on the api server to retain the ability to serve the front end app. It is toggled with `--console.frontend-enable`. github issue: #5843 Change-Id: I0d30451a20636e3184110dbe28c8a2a8a9505804
- Loading branch information
Showing
8 changed files
with
396 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (C) 2023 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/zeebo/errs" | ||
"go.uber.org/zap" | ||
|
||
"storj.io/private/process" | ||
"storj.io/storj/satellite" | ||
) | ||
|
||
func cmdUIRun(cmd *cobra.Command, args []string) (err error) { | ||
ctx, _ := process.Ctx(cmd) | ||
log := zap.L() | ||
|
||
runCfg.Debug.Address = *process.DebugAddrFlag | ||
|
||
identity, err := runCfg.Identity.Load() | ||
if err != nil { | ||
log.Error("Failed to load identity.", zap.Error(err)) | ||
return errs.New("Failed to load identity: %+v", err) | ||
} | ||
|
||
satAddr := runCfg.Config.Contact.ExternalAddress | ||
if satAddr == "" { | ||
return errs.New("cannot run satellite ui if contact.external-address is not set") | ||
} | ||
apiAddress := runCfg.Config.Console.ExternalAddress | ||
if apiAddress == "" { | ||
apiAddress = runCfg.Config.Console.Address | ||
} | ||
peer, err := satellite.NewUI(log, identity, &runCfg.Config, process.AtomicLevel(cmd), satAddr, apiAddress) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := process.InitMetricsWithHostname(ctx, log, nil); err != nil { | ||
log.Warn("Failed to initialize telemetry batcher on satellite api", zap.Error(err)) | ||
} | ||
|
||
runError := peer.Run(ctx) | ||
closeError := peer.Close() | ||
return errs.Combine(runError, closeError) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.