From d0201b23f127deae66837637c5244c328738b017 Mon Sep 17 00:00:00 2001 From: spinach <19keegandeppe@gmail.com> Date: Fri, 23 Jun 2023 15:27:30 -0400 Subject: [PATCH] fixing build scripts --- README.md | 2 +- Taskfile.dist.yml | 24 +++++++---- bin/{gotest.py => server-test.py} | 0 cmd/reactor/main.go | 72 ------------------------------- 4 files changed, 17 insertions(+), 81 deletions(-) rename bin/{gotest.py => server-test.py} (100%) delete mode 100644 cmd/reactor/main.go diff --git a/README.md b/README.md index 5d2700f..a9b82c4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DMAC +# dmac ## Distributed Monitoring and Control diff --git a/Taskfile.dist.yml b/Taskfile.dist.yml index 4f0d97f..5e1e342 100644 --- a/Taskfile.dist.yml +++ b/Taskfile.dist.yml @@ -4,21 +4,29 @@ tasks: clean: desc: "clean all of the old binaries" cmds: - - rm -vf bin/frms_* 2>/dev/null + - rm -vf bin/dmac_* 2>/dev/null test: desc: "Runs the full test suite" cmds: - - bin/gotest.py + - bin/test.py proto: desc: "Rebuilds protobuf for gRPC" cmds: - protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/pkg/grpc/*.proto + server: + desc: "builds arm/amd server binaries" + deps: [arm64-server, amd64-server] + + reactor: + desc: "builds arm reactor binaries" + deps: [arm32-reactor, arm64-reactor] + all: desc: "builds arm reactor binaries and arm/amd server binaries" - deps: [arm32-reactor, arm64-reactor, arm64-server, amd64-server] + deps: [reactor, server] arm32-reactor: desc: "Builds reactor binary for 32 bit arm linux device" @@ -42,7 +50,7 @@ tasks: arm64-server: desc: "Builds server binary for 64 bit arm linux device" cmds: - - task: go-build + - task: go-build-server vars: GOARCH: "arm64" GOOS: "linux" @@ -51,21 +59,21 @@ tasks: amd64-server: desc: "Builds server binary for amd linux machine" cmds: - - task: go-build + - task: go-build-server vars: GOARCH: "amd64" GOOS: "linux" BUILD_DIR: "server" - go-build: + go-build-server: internal: true cmds: - - go build -o bin/frms_{{.BUILD_DIR}}_{{.GOOS}}_{{.GOARCH}} cmd/{{.BUILD_DIR}}/main.go + - go build -o bin/dmac_server_{{.GOOS}}_{{.GOARCH}} server/main.go sources: - internal/pkg/**/*.go - cmd/{{.BUILD_DIR}}/main.go generates: - - bin/frms_{{.BUILD_DIR}}_{{.GOOS}}_{{.GOARCH}} + - bin/dmac_{{.BUILD_DIR}}_{{.GOOS}}_{{.GOARCH}} env: GOARM: "{{.GOARM}}" GOARCH: "{{.GOARCH}}" diff --git a/bin/gotest.py b/bin/server-test.py similarity index 100% rename from bin/gotest.py rename to bin/server-test.py diff --git a/cmd/reactor/main.go b/cmd/reactor/main.go deleted file mode 100644 index eb7e6a3..0000000 --- a/cmd/reactor/main.go +++ /dev/null @@ -1,72 +0,0 @@ -package main - -import ( - "FRMS/internal/pkg/config" - "FRMS/internal/pkg/logging" - "FRMS/internal/pkg/reactor" - "fmt" - "os" - "syscall" - - "os/signal" - - "github.com/spf13/viper" -) - -type reactorCoordinator interface { - Start() -} - -func NewReactorCoordinator( - config *viper.Viper, - ch chan error, -) (reactorCoordinator, error) { - // allows interface checking as opposed to calling directly - return reactor.NewCoordinator(config, ch) -} - -func main() { - // shutdown - gracefulShutdown := make(chan os.Signal, 1) - signal.Notify(gracefulShutdown, syscall.SIGINT, syscall.SIGTERM) - - // load any stored configs - home, err := os.UserHomeDir() - if err != nil { - panic(err) - } - - configPath := fmt.Sprintf("%s/.config/FRMS", home) - configFile := "reactor" - configExt := "yaml" - - conf, err := config.Load(configFile, configPath, configExt) - if err != nil { - panic(err) - } - - ch := make(chan error) - rlc, err := NewReactorCoordinator(conf, ch) // passing conf and err - if err != nil { - panic(err) - } - - go rlc.Start() - logging.Debug(logging.DStart, "Reactor Started") - - // check for errors - select { - case err := <-ch: - if err != nil { - conf.WriteConfig() // save changes - panic(err) - } - case <-gracefulShutdown: - // sigint - fmt.Printf("\nStoring config to %s\n", conf.ConfigFileUsed()) - if err := conf.WriteConfig(); err != nil { - panic(err) - } - os.Exit(0) - } -}