2022-12-25 12:49:45 -05:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
2023-01-19 09:57:50 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/upgrade-agent/internal/server"
|
2022-12-25 12:49:45 -05:00
|
|
|
"github.com/spf13/afero"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
protocol = "unix"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
gRPCDebug := flag.Bool("debug", false, "Enable gRPC debug logging")
|
|
|
|
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
log := logger.New(logger.JSONLog, logger.VerbosityFromInt(*verbosity)).Named("bootstrapper")
|
|
|
|
defer log.Sync()
|
|
|
|
|
|
|
|
if *gRPCDebug {
|
|
|
|
log.Named("gRPC").ReplaceGRPCLogger()
|
|
|
|
} else {
|
|
|
|
log.Named("gRPC").WithIncreasedLevel(zap.WarnLevel).ReplaceGRPCLogger()
|
|
|
|
}
|
|
|
|
|
|
|
|
handler := file.NewHandler(afero.NewOsFs())
|
2023-01-19 09:57:50 -05:00
|
|
|
server, err := server.New(log, handler)
|
2022-12-25 12:49:45 -05:00
|
|
|
if err != nil {
|
|
|
|
log.With(zap.Error(err)).Fatalf("Failed to create update server")
|
|
|
|
}
|
|
|
|
|
|
|
|
err = server.Run(protocol, constants.UpgradeAgentSocketPath)
|
|
|
|
if err != nil {
|
|
|
|
log.With(zap.Error(err)).Fatalf("Failed to start update server")
|
|
|
|
}
|
|
|
|
}
|