Skip to content

Commit

Permalink
start server in main
Browse files Browse the repository at this point in the history
  • Loading branch information
juancwu committed Dec 16, 2024
1 parent a89719a commit b875e53
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions backend/internal/server/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ func New() (*Server, error) {
/*
Start the server and binds it to the given port.
*/
func (s *Server) Start(port int) error {
return s.Echo.Start(fmt.Sprintf(":%d", port))
func (s *Server) Start(port string) error {
return s.Echo.Start(fmt.Sprintf(":%s", port))
}
31 changes: 15 additions & 16 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/rs/zerolog/log"

"KonferCA/SPUR/common"
// "KonferCA/SPUR/internal/server"
"KonferCA/SPUR/internal/server"
"github.com/joho/godotenv"
)

Expand All @@ -24,19 +24,18 @@ func main() {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339})
}

// TODO: replaced with new server
// s, err := server.New(false)
// if err != nil {
// log.Fatal().Err(err).Msg("failed to initialized server")
// }
//
// port := os.Getenv("PORT")
// if port == "" {
// port = "8080"
// }
//
// err = s.Listen(":" + os.Getenv("PORT"))
// if err != nil {
// log.Fatal().Err(err).Str("PORT", port).Msg("failed to bind server to start accepting connections.")
// }
s, err := server.New()
if err != nil {
log.Fatal().Err(err).Msg("failed to initialized server")
}

port := os.Getenv("PORT")
if port == "" {
port = "8080"
}

err = s.Start(port)
if err != nil {
log.Fatal().Err(err).Str("PORT", port).Msg("failed to bind server to start accepting connections.")
}
}

0 comments on commit b875e53

Please sign in to comment.