diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..1bc00f1c4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "realtime_dbms"] + path = realtime_dbms + url = https://github.com/mertyildiran/simple-realtime-dbms diff --git a/Dockerfile b/Dockerfile index 6ccd1b2ff..56179c854 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,9 @@ RUN go build -ldflags="-s -w \ COPY build_extensions.sh .. RUN cd .. && /bin/bash build_extensions.sh +COPY realtime_dbms ../realtime_dbms +RUN cd ../realtime_dbms/server && go build -o server server.go + FROM alpine:3.13.5 RUN apk add bash libpcap-dev tcpdump @@ -49,6 +52,7 @@ WORKDIR /app # Copy binary and config files from /build to root folder of scratch container. COPY --from=builder ["/app/agent-build/mizuagent", "."] +COPY --from=builder ["/app/realtime_dbms/server", "."] COPY --from=builder ["/app/agent/build/extensions", "extensions"] COPY --from=site-build ["/app/ui-build/build", "site"] diff --git a/Makefile b/Makefile index 722a5ff98..967182f80 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,7 @@ build-cli-ci: ## Build CLI for CI. agent: ## Build agent. @(echo "building mizu agent .." ) @(cd agent; go build -o build/mizuagent main.go) + ${MAKE} database ${MAKE} extensions @ls -l agent/build @@ -72,6 +73,10 @@ clean-cli: ## Clean CLI. clean-docker: @(echo "DOCKER cleanup - NOT IMPLEMENTED YET " ) +database: + @(echo "building database .." ) + @(cd realtime_dbms/server; go build -o ../../agent/build/server server.go) + extensions: ./build_extensions.sh diff --git a/agent/main.go b/agent/main.go index b19db67b3..2dc07ecc4 100644 --- a/agent/main.go +++ b/agent/main.go @@ -13,12 +13,14 @@ import ( "mizuserver/pkg/utils" "net/http" "os" + "os/exec" "os/signal" "path" "path/filepath" "plugin" "sort" "strings" + "time" "github.com/gin-contrib/static" "github.com/gin-gonic/gin" @@ -84,6 +86,19 @@ func main() { go pipeTapChannelToSocket(socketConnection, filteredOutputItemsChannel) // go pipeOutboundLinksChannelToSocket(socketConnection, outboundLinkOutputChannel) } else if *apiServerMode { + ex, err := os.Executable() + if err != nil { + log.Fatal(err) + } + dir := path.Dir(ex) + cmd := exec.Command(filepath.Join(dir, "./server"), "-port", "8000") + cmd.Stdout = os.Stdout + err = cmd.Start() + time.Sleep(1 * time.Second) + if err != nil { + log.Fatal(err) + } + api.StartResolving(*namespace) outputItemsChannel := make(chan *tapApi.OutputChannelItem) diff --git a/realtime_dbms b/realtime_dbms new file mode 160000 index 000000000..b86f10916 --- /dev/null +++ b/realtime_dbms @@ -0,0 +1 @@ +Subproject commit b86f10916f930db10c2f667f939f13a8743ef404