Skip to content

Commit

Permalink
Add new build target; Add cli flag --checker.dsn for database storage…
Browse files Browse the repository at this point in the history
… of found nodes

Signed-off-by: Anton Litvinov <[email protected]>
  • Loading branch information
Zensey committed Jul 29, 2024
1 parent 1c354be commit 03c6753
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 230 deletions.
28 changes: 23 additions & 5 deletions ci/packages/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,31 @@ import (
"github.com/rs/zerolog/log"
)

// BuildProvChecker builds myst binary with provider checker API. Like go tool, it supports cross-platform build with env vars: GOOS, GOARCH.
func BuildProvChecker() error {
logconfig.Bootstrap()
if err := buildBinary(path.Join("cmd", "mysterium_node", "mysterium_node.go"), "myst", true); err != nil {
return err
}
if err := copyConfig("myst"); err != nil {
return err
}
if err := buildBinary(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", false); err != nil {
return err
}
return nil
}

// Build builds the project. Like go tool, it supports cross-platform build with env vars: GOOS, GOARCH.
func Build() error {
logconfig.Bootstrap()
if err := buildBinary(path.Join("cmd", "mysterium_node", "mysterium_node.go"), "myst"); err != nil {
if err := buildBinary(path.Join("cmd", "mysterium_node", "mysterium_node.go"), "myst", false); err != nil {
return err
}
if err := copyConfig("myst"); err != nil {
return err
}
if err := buildBinary(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor"); err != nil {
if err := buildBinary(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", false); err != nil {
return err
}
return nil
Expand All @@ -67,7 +82,7 @@ func buildCrossBinary(os, arch string) error {
return sh.Run("bin/build_xgo", os+"/"+arch)
}

func buildBinary(source, target string) error {
func buildBinary(source, target string, provChecker bool) error {
targetOS, ok := os.LookupEnv("GOOS")
if !ok {
targetOS = runtime.GOOS
Expand All @@ -76,10 +91,10 @@ func buildBinary(source, target string) error {
if !ok {
targetArch = runtime.GOARCH
}
return buildBinaryFor(source, target, targetOS, targetArch, nil, false)
return buildBinaryFor(source, target, targetOS, targetArch, nil, false, provChecker)
}

func buildBinaryFor(source, target, targetOS, targetArch string, extraEnvs map[string]string, buildStatic bool) error {
func buildBinaryFor(source, target, targetOS, targetArch string, extraEnvs map[string]string, buildStatic, provChecker bool) error {
log.Info().Msgf("Building %s -> %s %s/%s", source, target, targetOS, targetArch)

buildDir, err := filepath.Abs(path.Join("build", target))
Expand All @@ -100,6 +115,9 @@ func buildBinaryFor(source, target, targetOS, targetArch string, extraEnvs map[s
if buildStatic {
flags = append(flags, "-a", "-tags", "netgo")
}
if provChecker {
flags = append(flags, "-tags", "prov_checker")
}

if targetOS == "windows" {
target += ".exe"
Expand Down
4 changes: 2 additions & 2 deletions ci/packages/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,15 @@ func packageStandalone(binaryPath, os, arch string, extraEnvs map[string]string)
if os == "linux" {
filename := path.Base(binaryPath)
binaryPath = path.Join("build", filename, filename)
err = buildBinaryFor(path.Join("cmd", "mysterium_node", "mysterium_node.go"), filename, os, arch, extraEnvs, true)
err = buildBinaryFor(path.Join("cmd", "mysterium_node", "mysterium_node.go"), filename, os, arch, extraEnvs, true, false)
} else {
err = buildCrossBinary(os, arch)
}
if err != nil {
return err
}

err = buildBinaryFor(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", os, arch, extraEnvs, true)
err = buildBinaryFor(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", os, arch, extraEnvs, true, false)
if err != nil {
return err
}
Expand Down
9 changes: 9 additions & 0 deletions config/flags_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ var (
Usage: "DNS listen port for services",
Value: 11253,
}

// FlagProvCheckerDatabaseDSN sets DNS for checker API database
FlagProvCheckerDatabaseDSN = cli.StringFlag{
Name: "checker.dsn",
Usage: "Database DSN for provider checker",
Value: "",
}
)

// RegisterFlagsNetwork function register network flags to flag list
Expand All @@ -179,6 +186,7 @@ func RegisterFlagsNetwork(flags *[]cli.Flag) {
&FlagPortCheckServers,
&FlagStatsReportInterval,
&FlagDNSListenPort,
&FlagProvCheckerDatabaseDSN,
)
}

Expand All @@ -203,6 +211,7 @@ func ParseFlagsNetwork(ctx *cli.Context) {
Current.ParseStringFlag(ctx, FlagPortCheckServers)
Current.ParseDurationFlag(ctx, FlagStatsReportInterval)
Current.ParseIntFlag(ctx, FlagDNSListenPort)
Current.ParseStringFlag(ctx, FlagProvCheckerDatabaseDSN)
}

// BlockchainNetwork defines a blockchain network
Expand Down
46 changes: 46 additions & 0 deletions tequilapi/endpoints/connection-diag-empty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//go:build !prov_checker

/*
* Copyright (C) 2024 The "MysteriumNetwork/node" Authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package endpoints

import (
"github.com/gin-gonic/gin"

"github.com/mysteriumnetwork/node/core/connection"
"github.com/mysteriumnetwork/node/core/node"
"github.com/mysteriumnetwork/node/eventbus"
"github.com/mysteriumnetwork/node/identity/selector"
)

// AddRoutesForConnectionDiag adds proder check route to given router
func AddRoutesForConnectionDiag(
manager connection.DiagManager,
stateProvider stateProvider,
proposalRepository proposalRepository,
identityRegistry identityRegistry,
publisher eventbus.Publisher,
subscriber eventbus.Subscriber,
addressProvider addressProvider,
identitySelector selector.Handler,
options node.Options,
) func(*gin.Engine) error {
return func(e *gin.Engine) error {
return nil
}
}
Loading

0 comments on commit 03c6753

Please sign in to comment.