Renamed module database into tasks
parent
375bb03dfe
commit
8845cb11de
14
Makefile
14
Makefile
|
@ -20,13 +20,13 @@ build:
|
|||
-trimpath -ldflags "-s -w -X ${PROJECT}/internal/diagnostics.Version=${RELEASE} \
|
||||
-X ${PROJECT}/internal/diagnostics.Commit=${COMMIT} \
|
||||
-X ${PROJECT}/internal/diagnostics.BuildDate=${BUILD_DATE} \
|
||||
-X ${PROJECT}/internal/database.Version=${RELEASE} \
|
||||
-X ${PROJECT}/internal/database.Commit=${COMMIT} \
|
||||
-X ${PROJECT}/internal/database.BuildDate=${BUILD_DATE} \
|
||||
-X ${PROJECT}/internal/database.Dbhost=${DBHOST} \
|
||||
-X ${PROJECT}/internal/database.Dbname=${DBNAME} \
|
||||
-X ${PROJECT}/internal/database.Dbuser=${DBUSER} \
|
||||
-X ${PROJECT}/internal/database.Dbpass=${DBPASS}" \
|
||||
-X ${PROJECT}/internal/tasks.Version=${RELEASE} \
|
||||
-X ${PROJECT}/internal/tasks.Commit=${COMMIT} \
|
||||
-X ${PROJECT}/internal/tasks.BuildDate=${BUILD_DATE} \
|
||||
-X ${PROJECT}/internal/tasks.Dbhost=${DBHOST} \
|
||||
-X ${PROJECT}/internal/tasks.Dbname=${DBNAME} \
|
||||
-X ${PROJECT}/internal/tasks.Dbuser=${DBUSER} \
|
||||
-X ${PROJECT}/internal/tasks.Dbpass=${DBPASS}" \
|
||||
-o bin/sysctl-${GOOS}-${GOARCH} ${PROJECT}/cmd/sysctl
|
||||
cp ./bin/sysctl-${GOOS}-${GOARCH} ./bin/sysctl
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/edgebox-iot/sysctl/internal/database"
|
||||
"github.com/edgebox-iot/sysctl/internal/diagnostics"
|
||||
"github.com/edgebox-iot/sysctl/internal/tasks"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -18,7 +18,8 @@ func main() {
|
|||
// load command line arguments
|
||||
|
||||
version := flag.Bool("version", false, "Get the version info")
|
||||
name := flag.String("name", "edgebox", "name for the service")
|
||||
db := flag.Bool("database", false, "Get database connection info")
|
||||
name := flag.String("name", "edgebox", "Name for the service")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -27,6 +28,11 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
if *db {
|
||||
printDbDetails()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
log.Printf("Starting Sysctl service for %s", *name)
|
||||
|
||||
// setup signal catching
|
||||
|
@ -47,8 +53,10 @@ func main() {
|
|||
}()
|
||||
|
||||
printVersion()
|
||||
|
||||
printDbDetails()
|
||||
dbQueryResult := database.PerformQuery()
|
||||
|
||||
dbQueryResult := tasks.PerformQuery()
|
||||
log.Printf("Query result: %s", dbQueryResult)
|
||||
|
||||
// infinite loop
|
||||
|
@ -75,7 +83,7 @@ func printVersion() {
|
|||
func printDbDetails() {
|
||||
fmt.Printf(
|
||||
"\n\nDatabase Connection Information:\nHost: %s\nuser: %s\npassword: %s\n\n",
|
||||
database.Dbhost, database.Dbuser, database.Dbpass,
|
||||
tasks.Dbhost, tasks.Dbuser, tasks.Dbpass,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
4
go.mod
4
go.mod
|
@ -2,9 +2,9 @@ module github.com/edgebox-iot/sysctl
|
|||
|
||||
go 1.15
|
||||
|
||||
replace github.com/edgebox-iot/sysctl/internal/database => ./internal/database
|
||||
replace github.com/edgebox-iot/sysctl/internal/tasks => ./internal/tasks
|
||||
|
||||
require (
|
||||
github.com/edgebox-iot/sysctl/internal/database v0.0.0-00010101000000-000000000000
|
||||
github.com/edgebox-iot/sysctl/internal/tasks v0.0.0-00010101000000-000000000000
|
||||
github.com/go-sql-driver/mysql v1.5.0 // indirect
|
||||
)
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
module github.com/edgebox-iot/sysctl/internal/database
|
||||
|
||||
go 1.15
|
|
@ -0,0 +1,3 @@
|
|||
module github.com/edgebox-iot/sysctl/internal/tasks
|
||||
|
||||
go 1.15
|
|
@ -1,14 +1,21 @@
|
|||
package database
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/go-sql-driver/mysql" // Mysql Driver
|
||||
)
|
||||
|
||||
// Dbhost : Database host (can be tweaked in makefile)
|
||||
var Dbhost string
|
||||
|
||||
// Dbname : Database name (can be tweaked in makefile)
|
||||
var Dbname string
|
||||
|
||||
// Dbuser : Database user (can be tweaked in makefile)
|
||||
var Dbuser string
|
||||
|
||||
// Dbpass : Database password (can be tweaked in)
|
||||
var Dbpass string
|
||||
|
||||
// PerformQuery : Performs a MySQL query over the device's Edgebox API
|
Loading…
Reference in New Issue