Skip to content

Commit

Permalink
[node-split] Add command for starting services
Browse files Browse the repository at this point in the history
Closes #6618
  • Loading branch information
jellonek committed Jan 16, 2025
1 parent 837e7fa commit f083f1d
Show file tree
Hide file tree
Showing 5 changed files with 1,266 additions and 610 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ FROM linux AS spacemesh

# Finally we copy the statically compiled Go binary.
COPY --from=builder /src/build/go-spacemesh /bin/
COPY --from=builder /src/build/service /bin/
COPY --from=builder /src/build/post-service /bin/
COPY --from=builder /src/build/libpost.so /bin/
COPY --from=builder /src/build/gen-p2p-identity /bin/
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ install:
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OAPI_CODEGEN_VERSION)
.PHONY: install

build: go-spacemesh get-profiler get-postrs-service
build: go-spacemesh get-profiler get-postrs-service service
.PHONY: build

get-libs: get-postrs-lib get-postrs-service
Expand All @@ -89,7 +89,11 @@ gen-p2p-identity:

go-spacemesh: get-libs
cd cmd/node ; go build -o $(BIN_DIR)$@$(EXE) $(LDFLAGS) .
.PHONY: go-spacemesh gen-p2p-identity
.PHONY: go-spacemesh

service: get-libs
cd cmd/service ; go build -o $(BIN_DIR)$@$(EXE) $(LDFLAGS) .
.PHONY: service

bootstrapper:
cd cmd/bootstrapper ; go build -o $(BIN_DIR)go-$@$(EXE) .
Expand Down
38 changes: 38 additions & 0 deletions cmd/service/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// go-spacemesh is a golang implementation of the Spacemesh node.
// See - https://spacemesh.io
package main

import (
_ "net/http/pprof"
"os"

"github.com/spf13/cobra"

"github.com/spacemeshos/go-spacemesh/cmd"
"github.com/spacemeshos/go-spacemesh/node"
)

var (
version string
commit string
branch string
noMainNet string
rootCmd = &cobra.Command{
Use: "service",
Short: "Start spacemesh service",
}
)

func main() { // run the app
cmd.Version = version
cmd.Commit = commit
cmd.Branch = branch
cmd.NoMainNet = noMainNet == "true"
rootCmd.AddCommand(node.GetCommand())
rootCmd.AddCommand(node.GetActivationServiceCommand())
if err := rootCmd.Execute(); err != nil {
// Do not print error as cmd.SilenceErrors is false
// and the error was already printed
os.Exit(1)
}
}
Loading

0 comments on commit f083f1d

Please sign in to comment.