2022-12-25 12:49:45 -05:00
|
|
|
/*
|
|
|
|
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"
|
2022-12-25 12:49:45 -05:00
|
|
|
|
|
|
|
"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"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
protocol = "unix"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
|
|
|
flag.Parse()
|
2024-06-05 03:24:08 -04:00
|
|
|
log := logger.NewJSONLogger(logger.VerbosityFromInt(*verbosity)).WithGroup("upgrade-agent")
|
|
|
|
logger.ReplaceGRPCLogger(
|
|
|
|
slog.New(
|
|
|
|
logger.NewLevelHandler(logger.VerbosityFromInt(*verbosity), log.Handler()),
|
|
|
|
).WithGroup("gRPC"),
|
|
|
|
)
|
2022-12-25 12:49:45 -05:00
|
|
|
|
|
|
|
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 {
|
2024-02-08 09:20:01 -05:00
|
|
|
log.With(slog.Any("error", err)).Error("Failed to create update server")
|
|
|
|
os.Exit(1)
|
2022-12-25 12:49:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2022-12-25 12:49:45 -05:00
|
|
|
}
|
|
|
|
}
|