Skip to content

Commit

Permalink
Updates system to start up DB
Browse files Browse the repository at this point in the history
  • Loading branch information
bomoko committed Dec 13, 2023
1 parent e58ad93 commit 7e11a4f
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,24 @@ func main() {
DSN: fmt.Sprintf("amqp://%s:%s@%s/", broker.Username, broker.Password, broker.Hostname),
}

db, err := service.SetUpDatabase(service.Dboptions{Filename: "database.sql"})
if err != nil {
slog.Error(err.Error())
os.Exit(1)
}

// Start up the web service if we need it
if !disableWebservice {

r, err := service.SetupRouter(db)
if err != nil {
slog.Error(err.Error())
os.Exit(1)
}

go r.Run(fmt.Sprintf("%v:%v", webserviceListenAddress, webservicePort))
}

// Start up the consumer if we need it
if !disableConsumer {
messaging := handler.NewMessaging(config,
Expand All @@ -222,29 +240,14 @@ func main() {
enableDebug,
problemsFromSBOM,
trivyServerEndpoint,
db,
)

// start the consumer
//slog.Info("insights-handler is started-up")
messaging.Consumer()
}

// Start up the web service if we need it
if !disableWebservice {
db, err := service.SetUpDatabase(service.Dboptions{Filename: "database.sql"})
if err != nil {
slog.Error(err.Error())
os.Exit(1)
}
r, err := service.SetupRouter(db)
if err != nil {
slog.Error(err.Error())
os.Exit(1)
}

r.Run(fmt.Sprintf("%v:%v", webserviceListenAddress, webservicePort))
}

}

func getEnv(key, fallback string) string {
Expand Down

0 comments on commit 7e11a4f

Please sign in to comment.