commit
34a21094ee
|
@ -30,7 +30,7 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v .
|
run: make build
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: go test -v .
|
run: go test -v ./...
|
||||||
|
|
|
@ -14,3 +14,7 @@ main
|
||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
|
|
||||||
|
# Build
|
||||||
|
|
||||||
|
/bin
|
||||||
|
|
|
@ -8,4 +8,4 @@ RUN go mod download
|
||||||
|
|
||||||
RUN go get github.com/githubnemo/CompileDaemon
|
RUN go get github.com/githubnemo/CompileDaemon
|
||||||
|
|
||||||
ENTRYPOINT CompileDaemon --build="go build main.go" --command=./main
|
ENTRYPOINT CompileDaemon --build="make build" --command=./bin/sysctl
|
|
@ -0,0 +1,23 @@
|
||||||
|
PROJECT?=github.com/edgebox-iot/sysctl
|
||||||
|
|
||||||
|
RELEASE ?= dev
|
||||||
|
COMMIT := $(shell git rev-parse --short HEAD)
|
||||||
|
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
|
||||||
|
BUILD_DIR = bin
|
||||||
|
|
||||||
|
build-all:
|
||||||
|
GOOS=linux GOARCH=amd64 make build
|
||||||
|
GOOS=linux GOARCH=arm make build
|
||||||
|
|
||||||
|
build:
|
||||||
|
@echo "Building ${GOOS}-${GOARCH}"
|
||||||
|
GOOS=${GOOS} GOARCH=${GOARCH} go build \
|
||||||
|
-trimpath -ldflags "-s -w -X ${PROJECT}/internal/diagnostics.Version=${RELEASE} \
|
||||||
|
-X ${PROJECT}/internal/diagnostics.Commit=${COMMIT} \
|
||||||
|
-X ${PROJECT}/internal/diagnostics.BuildDate=${BUILD_DATE}" \
|
||||||
|
-o bin/sysctl-${GOOS}-${GOARCH} ${PROJECT}/cmd/sysctl
|
||||||
|
cp ./bin/sysctl-${GOOS}-${GOARCH} ./bin/sysctl
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf ${BUILD_DIR}
|
||||||
|
go clean
|
|
@ -7,16 +7,24 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"time"
|
"time"
|
||||||
//"syscall"
|
//"syscall"
|
||||||
|
"github.com/edgebox-iot/sysctl/internal/diagnostics"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// load command line arguments
|
// load command line arguments
|
||||||
|
|
||||||
|
version := flag.Bool("version", false, "Get the version info")
|
||||||
name := flag.String("name", "edgebox", "name for the service")
|
name := flag.String("name", "edgebox", "name for the service")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *version {
|
||||||
|
printVersion()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("Starting Sysctl service for %s", *name)
|
log.Printf("Starting Sysctl service for %s", *name)
|
||||||
|
|
||||||
// setup signal catching
|
// setup signal catching
|
||||||
|
@ -32,7 +40,7 @@ func main() {
|
||||||
go func() {
|
go func() {
|
||||||
s := <-sigs
|
s := <-sigs
|
||||||
log.Printf("RECEIVED SIGNAL: %s", s)
|
log.Printf("RECEIVED SIGNAL: %s", s)
|
||||||
AppCleanup()
|
appCleanup()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -50,6 +58,13 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppCleanup : cleanup app state before exit
|
// AppCleanup : cleanup app state before exit
|
||||||
func AppCleanup() {
|
func appCleanup() {
|
||||||
log.Println("Cleaning up app status before exit")
|
log.Println("Cleaning up app status before exit")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printVersion() {
|
||||||
|
fmt.Printf(
|
||||||
|
"version: %s\ncommit: %s\nbuild time: %s",
|
||||||
|
diagnostics.Version, diagnostics.Commit, diagnostics.BuildDate,
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package diagnostics
|
||||||
|
|
||||||
|
var Version string
|
||||||
|
|
||||||
|
var Commit string
|
||||||
|
|
||||||
|
var BuildDate string
|
Loading…
Reference in New Issue