Added database module with exportable functions

This commit is contained in:
Paulo Truta
2021-02-13 15:51:14 +01:00
parent 28cb163f6d
commit 375bb03dfe
6 changed files with 83 additions and 5 deletions
+15 -2
View File
@@ -6,9 +6,10 @@ import (
"log"
"os"
"os/signal"
"time"
"syscall"
"time"
"github.com/edgebox-iot/sysctl/internal/database"
"github.com/edgebox-iot/sysctl/internal/diagnostics"
)
@@ -45,6 +46,11 @@ func main() {
os.Exit(1)
}()
printVersion()
printDbDetails()
dbQueryResult := database.PerformQuery()
log.Printf("Query result: %s", dbQueryResult)
// infinite loop
for {
@@ -61,11 +67,18 @@ func appCleanup() {
func printVersion() {
fmt.Printf(
"version: %s\ncommit: %s\nbuild time: %s",
"\nversion: %s\ncommit: %s\nbuild time: %s\n",
diagnostics.Version, diagnostics.Commit, diagnostics.BuildDate,
)
}
func printDbDetails() {
fmt.Printf(
"\n\nDatabase Connection Information:\nHost: %s\nuser: %s\npassword: %s\n\n",
database.Dbhost, database.Dbuser, database.Dbpass,
)
}
// IsSystemReady : Checks hability of the service to execute commands (Only after "edgebox --build" is ran at least once via SSH, or if built for distribution)
func isSystemReady() bool {
_, err := os.Stat("/home/system/components/ws")