fixing build scripts

main
spinach 2 years ago
parent ab5f21d211
commit d0201b23f1

@ -1,4 +1,4 @@
# DMAC
# dmac
## Distributed Monitoring and Control

@ -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}}"

@ -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)
}
}
Loading…
Cancel
Save