kopia lustrzana https://github.com/bugout-dev/moonstream
Cli config file for node list setup
rodzic
12be151b9d
commit
d6db6878d5
|
@ -1,5 +1,65 @@
|
||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,go
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,go
|
||||||
|
|
||||||
|
### Go ###
|
||||||
|
# If you prefer the allow list template instead of the deny list, see community template:
|
||||||
|
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||||
|
#
|
||||||
|
# Binaries for programs and plugins
|
||||||
|
*.exe
|
||||||
|
*.exe~
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Test binary, built with `go test -c`
|
||||||
|
*.test
|
||||||
|
|
||||||
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Dependency directories (remove the comment below to include it)
|
||||||
|
# vendor/
|
||||||
|
|
||||||
|
# Go workspace file
|
||||||
|
go.work
|
||||||
|
|
||||||
|
### Go Patch ###
|
||||||
|
/vendor/
|
||||||
|
/Godeps/
|
||||||
|
|
||||||
|
### VisualStudioCode ###
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/*.code-snippets
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Built Visual Studio Code Extensions
|
||||||
|
*.vsix
|
||||||
|
|
||||||
|
### VisualStudioCode Patch ###
|
||||||
|
# Ignore all local history of files
|
||||||
|
.history
|
||||||
|
.ionide
|
||||||
|
|
||||||
|
# Support for Project snippet scope
|
||||||
|
.vscode/*.code-snippets
|
||||||
|
|
||||||
|
# Ignore code-workspaces
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,go
|
||||||
|
|
||||||
# Custom
|
# Custom
|
||||||
.secrets/*
|
.secrets/*
|
||||||
dev.env
|
dev.env
|
||||||
prod.env
|
prod.env
|
||||||
test.env
|
test.env
|
||||||
|
nodebalancer
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bugout-dev/moonstream/nodes/node_balancer/configs"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
stateCLI StateCLI
|
||||||
|
)
|
||||||
|
|
||||||
|
type flagSlice []string
|
||||||
|
|
||||||
|
func (i *flagSlice) String() string {
|
||||||
|
return strings.Join(*i, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *flagSlice) Set(value string) error {
|
||||||
|
*i = append(*i, value)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command Line Interface state
|
||||||
|
type StateCLI struct {
|
||||||
|
serverCmd *flag.FlagSet
|
||||||
|
versionCmd *flag.FlagSet
|
||||||
|
|
||||||
|
// Common flags
|
||||||
|
configPathFlag string
|
||||||
|
helpFlag bool
|
||||||
|
|
||||||
|
// Server flags
|
||||||
|
listeningAddrFlag string
|
||||||
|
listeningPortFlag string
|
||||||
|
nodesFlag flagSlice
|
||||||
|
enableHealthCheckFlag bool
|
||||||
|
enableDebugFlag bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StateCLI) usage() {
|
||||||
|
fmt.Printf(`usage: nodebalancer [-h] {%[1]s,%[2]s} ...
|
||||||
|
Moonstream node balancer CLI
|
||||||
|
optional arguments:
|
||||||
|
-h, --help show this help message and exit
|
||||||
|
|
||||||
|
subcommands:
|
||||||
|
{%[1]s,%[2]s}
|
||||||
|
`, s.serverCmd.Name(), s.versionCmd.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StateCLI) checkRequirements() {
|
||||||
|
if s.helpFlag {
|
||||||
|
switch {
|
||||||
|
case s.serverCmd.Parsed():
|
||||||
|
fmt.Printf("Start nodebalancer server\n\n")
|
||||||
|
s.serverCmd.PrintDefaults()
|
||||||
|
os.Exit(0)
|
||||||
|
case s.versionCmd.Parsed():
|
||||||
|
fmt.Printf("Show version\n\n")
|
||||||
|
s.versionCmd.PrintDefaults()
|
||||||
|
os.Exit(0)
|
||||||
|
default:
|
||||||
|
s.usage()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.configPathFlag == "" {
|
||||||
|
homeDir, err := os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to find user home directory, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
configDirPath := fmt.Sprintf("%s/.nodebalancer", homeDir)
|
||||||
|
configPath := fmt.Sprintf("%s/config.txt", configDirPath)
|
||||||
|
|
||||||
|
err = os.MkdirAll(configDirPath, os.ModePerm)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to create directory, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = os.Stat(configPath)
|
||||||
|
if err != nil {
|
||||||
|
tempConfigB := []byte("ethereum,http://127.0.0.1,8545")
|
||||||
|
err = os.WriteFile(configPath, tempConfigB, 0644)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to write config, %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s.configPathFlag = configPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StateCLI) populateCLI() {
|
||||||
|
// Subcommands setup
|
||||||
|
s.serverCmd = flag.NewFlagSet("server", flag.ExitOnError)
|
||||||
|
s.versionCmd = flag.NewFlagSet("version", flag.ExitOnError)
|
||||||
|
|
||||||
|
// Common flag pointers
|
||||||
|
for _, fs := range []*flag.FlagSet{s.serverCmd, s.versionCmd} {
|
||||||
|
fs.BoolVar(&s.helpFlag, "help", false, "Show help message")
|
||||||
|
fs.StringVar(&s.configPathFlag, "config", "", "Path to configuration file (default: ~/.nodebalancer/config.txt)")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Server subcommand flag pointers
|
||||||
|
s.serverCmd.StringVar(&s.listeningAddrFlag, "host", "127.0.0.1", "Server listening address")
|
||||||
|
s.serverCmd.StringVar(&s.listeningPortFlag, "port", "8544", "Server listening port")
|
||||||
|
s.serverCmd.BoolVar(&s.enableHealthCheckFlag, "healthcheck", false, "To enable healthcheck ser healthcheck flag")
|
||||||
|
s.serverCmd.BoolVar(&s.enableDebugFlag, "debug", false, "To enable debug mode with extended log set debug flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
func CLI() {
|
||||||
|
stateCLI.populateCLI()
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
stateCLI.usage()
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse subcommands and appropriate FlagSet
|
||||||
|
switch os.Args[1] {
|
||||||
|
case "server":
|
||||||
|
stateCLI.serverCmd.Parse(os.Args[2:])
|
||||||
|
stateCLI.checkRequirements()
|
||||||
|
|
||||||
|
Server()
|
||||||
|
|
||||||
|
case "version":
|
||||||
|
stateCLI.versionCmd.Parse(os.Args[2:])
|
||||||
|
stateCLI.checkRequirements()
|
||||||
|
|
||||||
|
fmt.Printf("v%s\n", configs.NB_VERSION)
|
||||||
|
|
||||||
|
default:
|
||||||
|
stateCLI.usage()
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,13 +8,17 @@ import (
|
||||||
configs "github.com/bugout-dev/moonstream/nodes/node_balancer/configs"
|
configs "github.com/bugout-dev/moonstream/nodes/node_balancer/configs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ethereumClientPool ClientPool
|
var (
|
||||||
var polygonClientPool ClientPool
|
ethereumClientPool ClientPool
|
||||||
|
polygonClientPool ClientPool
|
||||||
|
xdaiClientPool ClientPool
|
||||||
|
)
|
||||||
|
|
||||||
// Generate client pools for different blockchains
|
// Generate client pools for different blockchains
|
||||||
func CreateClientPools() {
|
func CreateClientPools() {
|
||||||
ethereumClientPool.Client = make(map[string]*Client)
|
ethereumClientPool.Client = make(map[string]*Client)
|
||||||
polygonClientPool.Client = make(map[string]*Client)
|
polygonClientPool.Client = make(map[string]*Client)
|
||||||
|
xdaiClientPool.Client = make(map[string]*Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return client pool correspongin to blockchain
|
// Return client pool correspongin to blockchain
|
||||||
|
@ -24,6 +28,8 @@ func GetClientPool(blockchain string) (*ClientPool, error) {
|
||||||
cpool = ðereumClientPool
|
cpool = ðereumClientPool
|
||||||
} else if blockchain == "polygon" {
|
} else if blockchain == "polygon" {
|
||||||
cpool = &polygonClientPool
|
cpool = &polygonClientPool
|
||||||
|
} else if blockchain == "xdai" {
|
||||||
|
cpool = &xdaiClientPool
|
||||||
} else {
|
} else {
|
||||||
return nil, errors.New("Unexisting blockchain provided")
|
return nil, errors.New("Unexisting blockchain provided")
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ func lbHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
blockchain = "ethereum"
|
blockchain = "ethereum"
|
||||||
case strings.HasPrefix(r.URL.Path, "/nb/polygon"):
|
case strings.HasPrefix(r.URL.Path, "/nb/polygon"):
|
||||||
blockchain = "polygon"
|
blockchain = "polygon"
|
||||||
|
case strings.HasPrefix(r.URL.Path, "/nb/xdai"):
|
||||||
|
blockchain = "xdai"
|
||||||
default:
|
default:
|
||||||
http.Error(w, fmt.Sprintf("Unacceptable blockchain provided %s", blockchain), http.StatusBadRequest)
|
http.Error(w, fmt.Sprintf("Unacceptable blockchain provided %s", blockchain), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
|
|
@ -5,12 +5,12 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
humbug "github.com/bugout-dev/humbug/go/pkg"
|
humbug "github.com/bugout-dev/humbug/go/pkg"
|
||||||
|
@ -29,7 +29,8 @@ func initHealthCheck(debug bool) {
|
||||||
blockchainPool.HealthCheck()
|
blockchainPool.HealthCheck()
|
||||||
ethereumClients := ethereumClientPool.CleanInactiveClientNodes()
|
ethereumClients := ethereumClientPool.CleanInactiveClientNodes()
|
||||||
polygonClients := polygonClientPool.CleanInactiveClientNodes()
|
polygonClients := polygonClientPool.CleanInactiveClientNodes()
|
||||||
log.Printf("Active etehereum clients: %d, polygon clients: %d\n", ethereumClients, polygonClients)
|
xdaiClients := xdaiClientPool.CleanInactiveClientNodes()
|
||||||
|
log.Printf("Active etehereum clients: %d, polygon clients: %d, xdai clients: %d\n", ethereumClients, polygonClients, xdaiClients)
|
||||||
if debug {
|
if debug {
|
||||||
blockchainPool.StatusLog()
|
blockchainPool.StatusLog()
|
||||||
}
|
}
|
||||||
|
@ -92,24 +93,7 @@ func proxyErrorHandler(proxy *httputil.ReverseProxy, url *url.URL) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitServer() {
|
func Server() {
|
||||||
var listeningAddr string
|
|
||||||
var listeningPort string
|
|
||||||
var enableHealthCheck bool
|
|
||||||
var enableDebug bool
|
|
||||||
var showVersion bool
|
|
||||||
flag.StringVar(&listeningAddr, "host", "127.0.0.1", "Server listening address")
|
|
||||||
flag.StringVar(&listeningPort, "port", "8544", "Server listening port")
|
|
||||||
flag.BoolVar(&enableHealthCheck, "healthcheck", false, "To enable healthcheck ser healthcheck flag")
|
|
||||||
flag.BoolVar(&enableDebug, "debug", false, "To enable debug mode with extended log set debug flag")
|
|
||||||
flag.BoolVar(&showVersion, "version", false, "Print version")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
if showVersion {
|
|
||||||
fmt.Printf("Node balancer version: v%s\n", configs.NODE_BALANCER_VERSION)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate map of clients
|
// Generate map of clients
|
||||||
CreateClientPools()
|
CreateClientPools()
|
||||||
|
|
||||||
|
@ -125,7 +109,11 @@ func InitServer() {
|
||||||
reporter.Publish(humbug.SystemReport())
|
reporter.Publish(humbug.SystemReport())
|
||||||
|
|
||||||
// Fill NodeConfigList with initial nodes from environment variables
|
// Fill NodeConfigList with initial nodes from environment variables
|
||||||
configs.ConfigList.InitNodeConfigList()
|
configs.ConfigList.InitNodeConfigList(stateCLI.configPathFlag)
|
||||||
|
|
||||||
|
fmt.Println(configs.ConfigList)
|
||||||
|
|
||||||
|
os.Exit(1)
|
||||||
|
|
||||||
// Parse nodes and set list of proxies
|
// Parse nodes and set list of proxies
|
||||||
for i, nodeConfig := range configs.ConfigList.Configs {
|
for i, nodeConfig := range configs.ConfigList.Configs {
|
||||||
|
@ -165,18 +153,18 @@ func InitServer() {
|
||||||
commonHandler = panicMiddleware(commonHandler)
|
commonHandler = panicMiddleware(commonHandler)
|
||||||
|
|
||||||
server := http.Server{
|
server := http.Server{
|
||||||
Addr: fmt.Sprintf("%s:%s", listeningAddr, listeningPort),
|
Addr: fmt.Sprintf("%s:%s", stateCLI.listeningAddrFlag, stateCLI.listeningPortFlag),
|
||||||
Handler: commonHandler,
|
Handler: commonHandler,
|
||||||
ReadTimeout: 10 * time.Second,
|
ReadTimeout: 10 * time.Second,
|
||||||
WriteTimeout: 10 * time.Second,
|
WriteTimeout: 10 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start node health checking and current block fetching
|
// Start node health checking and current block fetching
|
||||||
if enableHealthCheck {
|
if stateCLI.enableHealthCheckFlag {
|
||||||
go initHealthCheck(enableDebug)
|
go initHealthCheck(stateCLI.enableDebugFlag)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Starting server at %s:%s\n", listeningAddr, listeningPort)
|
log.Printf("Starting server at %s:%s\n", stateCLI.listeningAddrFlag, stateCLI.listeningPortFlag)
|
||||||
err = server.ListenAndServe()
|
err = server.ListenAndServe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -4,9 +4,11 @@ Configurations for load balancer server.
|
||||||
package configs
|
package configs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,67 +30,43 @@ type NodeConfigList struct {
|
||||||
|
|
||||||
var ConfigList NodeConfigList
|
var ConfigList NodeConfigList
|
||||||
|
|
||||||
var MOONSTREAM_NODE_ETHEREUM_A_IPC_ADDR = os.Getenv("MOONSTREAM_NODE_ETHEREUM_A_IPC_ADDR")
|
|
||||||
var MOONSTREAM_NODE_ETHEREUM_B_IPC_ADDR = os.Getenv("MOONSTREAM_NODE_ETHEREUM_B_IPC_ADDR")
|
|
||||||
var MOONSTREAM_NODE_ETHEREUM_IPC_PORT = os.Getenv("MOONSTREAM_NODE_ETHEREUM_IPC_PORT")
|
|
||||||
var MOONSTREAM_NODE_POLYGON_A_IPC_ADDR = os.Getenv("MOONSTREAM_NODE_POLYGON_A_IPC_ADDR")
|
|
||||||
var MOONSTREAM_NODE_POLYGON_B_IPC_ADDR = os.Getenv("MOONSTREAM_NODE_POLYGON_B_IPC_ADDR")
|
|
||||||
var MOONSTREAM_NODE_POLYGON_IPC_PORT = os.Getenv("MOONSTREAM_NODE_POLYGON_IPC_PORT")
|
|
||||||
var MOONSTREAM_NODES_SERVER_PORT = os.Getenv("MOONSTREAM_NODES_SERVER_PORT")
|
var MOONSTREAM_NODES_SERVER_PORT = os.Getenv("MOONSTREAM_NODES_SERVER_PORT")
|
||||||
var MOONSTREAM_CLIENT_ID_HEADER = os.Getenv("MOONSTREAM_CLIENT_ID_HEADER")
|
var MOONSTREAM_CLIENT_ID_HEADER = os.Getenv("MOONSTREAM_CLIENT_ID_HEADER")
|
||||||
|
|
||||||
func checkEnvVarSet() {
|
func checkEnvVarSet() {
|
||||||
if MOONSTREAM_NODE_ETHEREUM_A_IPC_ADDR == "" {
|
|
||||||
MOONSTREAM_NODE_ETHEREUM_A_IPC_ADDR = "a.ethereum.moonstream.internal"
|
|
||||||
}
|
|
||||||
if MOONSTREAM_NODE_ETHEREUM_B_IPC_ADDR == "" {
|
|
||||||
MOONSTREAM_NODE_ETHEREUM_B_IPC_ADDR = "b.ethereum.moonstream.internal"
|
|
||||||
}
|
|
||||||
|
|
||||||
if MOONSTREAM_NODE_POLYGON_A_IPC_ADDR == "" {
|
|
||||||
MOONSTREAM_NODE_POLYGON_A_IPC_ADDR = "a.polygon.moonstream.internal"
|
|
||||||
}
|
|
||||||
if MOONSTREAM_NODE_POLYGON_B_IPC_ADDR == "" {
|
|
||||||
MOONSTREAM_NODE_POLYGON_B_IPC_ADDR = "b.polygon.moonstream.internal"
|
|
||||||
}
|
|
||||||
|
|
||||||
if MOONSTREAM_CLIENT_ID_HEADER == "" {
|
if MOONSTREAM_CLIENT_ID_HEADER == "" {
|
||||||
MOONSTREAM_CLIENT_ID_HEADER = "x-moonstream-client-id"
|
MOONSTREAM_CLIENT_ID_HEADER = "x-moonstream-client-id"
|
||||||
}
|
}
|
||||||
|
|
||||||
if MOONSTREAM_NODES_SERVER_PORT == "" || MOONSTREAM_NODE_ETHEREUM_IPC_PORT == "" || MOONSTREAM_NODE_POLYGON_IPC_PORT == "" {
|
if MOONSTREAM_NODES_SERVER_PORT == "" {
|
||||||
log.Fatal("Some of environment variables not set")
|
log.Fatal("Environment variable MOONSTREAM_NODES_SERVER_PORT not set")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return list of NodeConfig structures
|
// Return list of NodeConfig structures
|
||||||
func (nc *NodeConfigList) InitNodeConfigList() {
|
func (nc *NodeConfigList) InitNodeConfigList(configPath string) {
|
||||||
checkEnvVarSet()
|
checkEnvVarSet()
|
||||||
|
|
||||||
// Define available blockchain nodes
|
rawBytes, err := ioutil.ReadFile(configPath)
|
||||||
blockchainConfigList := make([]BlockchainConfig, 0, 2)
|
|
||||||
blockchainConfigList = append(blockchainConfigList, BlockchainConfig{
|
|
||||||
Blockchain: "ethereum",
|
|
||||||
IPs: []string{MOONSTREAM_NODE_ETHEREUM_A_IPC_ADDR, MOONSTREAM_NODE_ETHEREUM_B_IPC_ADDR},
|
|
||||||
Port: MOONSTREAM_NODE_ETHEREUM_IPC_PORT,
|
|
||||||
})
|
|
||||||
blockchainConfigList = append(blockchainConfigList, BlockchainConfig{
|
|
||||||
Blockchain: "polygon",
|
|
||||||
IPs: []string{MOONSTREAM_NODE_POLYGON_A_IPC_ADDR, MOONSTREAM_NODE_POLYGON_B_IPC_ADDR},
|
|
||||||
Port: MOONSTREAM_NODE_POLYGON_IPC_PORT,
|
|
||||||
})
|
|
||||||
|
|
||||||
// Parse node addr, ip and blockchain
|
|
||||||
for _, b := range blockchainConfigList {
|
|
||||||
for _, nodeIP := range b.IPs {
|
|
||||||
port, err := strconv.ParseInt(b.Port, 0, 16)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Unable to parse port number: %s", b.Port)
|
log.Fatalf("Unable to read config file, %v", err)
|
||||||
|
}
|
||||||
|
text := string(rawBytes)
|
||||||
|
lines := strings.Split(text, "\n")
|
||||||
|
|
||||||
|
// Define available blockchain nodes
|
||||||
|
for _, line := range lines {
|
||||||
|
fields := strings.Split(line, ",")
|
||||||
|
if len(fields) == 3 {
|
||||||
|
port, err := strconv.ParseInt(fields[2], 0, 16)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Unable to parse port number, %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.Configs = append(nc.Configs, NodeConfig{
|
nc.Configs = append(nc.Configs, NodeConfig{
|
||||||
Blockchain: b.Blockchain,
|
Blockchain: fields[0],
|
||||||
Addr: nodeIP,
|
Addr: fields[1],
|
||||||
Port: uint16(port),
|
Port: uint16(port),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
package configs
|
package configs
|
||||||
|
|
||||||
var NODE_BALANCER_VERSION = "0.0.1"
|
var NB_VERSION = "0.0.1"
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# Compile application and run with provided arguments
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PROGRAM_NAME="nodebalancer"
|
||||||
|
|
||||||
|
go build -o "$PROGRAM_NAME" .
|
||||||
|
|
||||||
|
./"$PROGRAM_NAME" "$@"
|
|
@ -5,5 +5,5 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cmd.InitServer()
|
cmd.CLI()
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue