constellation/upgrade-agent/cmd/main.go

51 lines
1.2 KiB
Go
Raw Normal View History

/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package main
import (
"flag"
2024-02-08 09:20:01 -05:00
"log/slog"
"os"
"github.com/edgelesssys/constellation/v2/internal/constants"
"github.com/edgelesssys/constellation/v2/internal/file"
"github.com/edgelesssys/constellation/v2/internal/logger"
"github.com/edgelesssys/constellation/v2/upgrade-agent/internal/server"
"github.com/spf13/afero"
)
const (
protocol = "unix"
)
func main() {
gRPCDebug := flag.Bool("debug", false, "Enable gRPC debug logging")
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
flag.Parse()
2024-02-08 09:20:01 -05:00
log := logger.NewJSONLogger(logger.VerbosityFromInt(*verbosity)).WithGroup("bootstrapper")
if *gRPCDebug {
2024-02-08 09:20:01 -05:00
logger.ReplaceGRPCLogger(log.WithGroup("gRPC"))
} else {
2024-02-08 09:20:01 -05:00
logger.ReplaceGRPCLogger(slog.New(logger.NewLevelHandler(slog.LevelWarn, log.Handler())).WithGroup("gRPC"))
}
handler := file.NewHandler(afero.NewOsFs())
server, err := server.New(log, handler)
if err != nil {
2024-02-08 09:20:01 -05:00
log.With(slog.Any("error", err)).Error("Failed to create update server")
os.Exit(1)
}
err = server.Run(protocol, constants.UpgradeAgentSocketPath)
if err != nil {
2024-02-08 09:20:01 -05:00
log.With(slog.Any("error", err)).Error("Failed to start update server")
os.Exit(1)
}
}