Skip to content

Commit

Permalink
* fix PORT bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JGottschick committed Sep 23, 2024
1 parent 8ba92d0 commit d26d8e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions templates/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ USER appuser:appuser
EXPOSE {{ .Port }}
# Run the app binary
CMD ["/go/bin/app"]
# CMD ["/go/bin/app","-d"]
11 changes: 7 additions & 4 deletions templates/core/config.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Config struct {
Sid string `ignored:"true"`
Name string `default:"{{.ModuleName}}"`
Title string
Port string `default:"8080"`
PortNb string `default:"8080"` // Port is a reserved name in k8s
ApiKeys []string `default:"" split_words:"true"`
AuthorizationHeader string `default:"" split_words:"true"`
SessionKey string `default:"" split_words:"true"`
Expand Down Expand Up @@ -55,12 +55,15 @@ func init() {
AppConfig.Sid = sid.String()

// parse command line arguments
flag.StringVar(&AppConfig.Port, "port", AppConfig.Port, "AppConfig.Port to listen by the server")
flag.StringVar(&AppConfig.Port, "p", AppConfig.Port, "AppConfig.Port to listen by the server")
flag.StringVar(&AppConfig.PortNb, "port", AppConfig.PortNb, "AppConfig.PortNb to listen by the server")
flag.StringVar(&AppConfig.PortNb, "p", AppConfig.PortNb, "AppConfig.PortNb to listen by the server")
flag.StringVar(&AppConfig.Name, "name", AppConfig.Name, "Name of the service")
flag.StringVar(&AppConfig.Name, "n", AppConfig.Name, "Name of the service")
flag.BoolVar(&AppConfig.Debug, "d", AppConfig.Debug, "enable debugging level for logging")
flag.BoolVar(&AppConfig.Version, "V", AppConfig.Version, "print version")
flag.Parse()

log.Debug().Str("name", AppConfig.Name).Any("environment", os.Environ()).Msg("Got environment")

if AppConfig.Name == "" {
AppConfig.Name = service
Expand Down Expand Up @@ -97,6 +100,6 @@ func init() {
AppConfig.SessionKey = AppConfig.Name
}

log.Debug().Str("name", AppConfig.Name).Any("environment", AppConfig).Msg("Got environment")
log.Debug().Str("name", AppConfig.Name).Any("config", AppConfig).Msg("Got configuration")
AppInfo.Name = AppConfig.Name
}
6 changes: 3 additions & 3 deletions templates/main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var embeddedFS embed.FS
func main() {
// ToDo: Add basic command line options as _-n_/_-name_ and _-d_/_-debug_ using flags

log.Info().Msg("Starting service")
log.Info().Str("port", core.AppConfig.PortNb).Msg("Starting service")

// init Opentelemetry
if core.AppConfig.Tracing {
Expand Down Expand Up @@ -74,8 +74,8 @@ func main() {


if core.AppConfig.CertPem != "" && core.AppConfig.KeyPem != "" {
e.Logger.Fatal(e.StartTLS(":" + core.AppConfig.Port, []byte(core.AppConfig.CertPem), []byte(core.AppConfig.KeyPem)))
e.Logger.Fatal(e.StartTLS(":" + core.AppConfig.PortNb, []byte(core.AppConfig.CertPem), []byte(core.AppConfig.KeyPem)))
} else {
e.Logger.Fatal(e.Start(":" + core.AppConfig.Port))
e.Logger.Fatal(e.Start(":" + core.AppConfig.PortNb))
}
}

0 comments on commit d26d8e3

Please sign in to comment.