Fixed Dockerfile and compose files for auto re-build, added loop for system service behaviour
parent
78b89a107b
commit
0c2fd3066e
|
@ -4,6 +4,7 @@
|
||||||
*.dll
|
*.dll
|
||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
|
main
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
# Test binary, built with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
|
|
|
@ -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=./runsysctl
|
ENTRYPOINT CompileDaemon --build="go build main.go" --command=./main
|
|
@ -4,5 +4,3 @@ services:
|
||||||
build: ./
|
build: ./
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/app
|
- ./:/app
|
||||||
edgebox-queue:
|
|
||||||
image: redis-alpine
|
|
61
main.go
61
main.go
|
@ -1,20 +1,55 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"flag"
|
||||||
"github.com/go-redis/redis/v8"
|
"log"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"time"
|
||||||
|
//"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
fmt.Println("Hello World")
|
// load command line arguments
|
||||||
|
|
||||||
// client := redis.NewClient(&redis.Options{
|
name := flag.String("name", "edgebox", "name for the service")
|
||||||
// Addr: "edgebox-queue:6379",
|
|
||||||
// Password: "", // no password set
|
flag.Parse()
|
||||||
// DB: 0, // use default DB
|
|
||||||
// })
|
log.Printf("Starting Sysctl service for %s", *name)
|
||||||
// pong, err := client.Ping().Result()
|
|
||||||
// fmt.Println(pong, err)
|
// setup signal catching
|
||||||
|
sigs := make(chan os.Signal, 1)
|
||||||
}
|
|
||||||
|
// catch all signals since not explicitly listing
|
||||||
|
signal.Notify(sigs)
|
||||||
|
|
||||||
|
// Cathing specific signals can be done with:
|
||||||
|
//signal.Notify(sigs,syscall.SIGQUIT)
|
||||||
|
|
||||||
|
// method invoked upon seeing signal
|
||||||
|
go func() {
|
||||||
|
s := <-sigs
|
||||||
|
log.Printf("RECEIVED SIGNAL: %s", s)
|
||||||
|
AppCleanup()
|
||||||
|
os.Exit(1)
|
||||||
|
}()
|
||||||
|
|
||||||
|
// infinite loop
|
||||||
|
for {
|
||||||
|
|
||||||
|
log.Printf("Executing instruction %s", *name)
|
||||||
|
|
||||||
|
// wait random number of milliseconds
|
||||||
|
Nsecs := 1000
|
||||||
|
log.Printf("Next instruction executed in %dms", Nsecs)
|
||||||
|
time.Sleep(time.Millisecond * time.Duration(Nsecs))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppCleanup : cleanup app state before exit
|
||||||
|
func AppCleanup() {
|
||||||
|
log.Println("Cleaning up app status before exit")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue