Skip to content

Commit

Permalink
Merge develop into master (#66)
Browse files Browse the repository at this point in the history
* add /dmsghttp config to config bootstrap

* fix images

* fix integration env configs

* update docker-compose

* add monitors to env_test values

* remove useless config

* update logic of reading config of vpn and public-visor monitors

* fix docker-compose config

* export RootCmd(s)

* update go.mod & vendor

* fix build docker images for pods

* update Makefile

* update go.mod go.sum vendor

* update go.mod with skywire & skywire-utilities v1.3.11

* fix images

* fix docker_build.sh script

* fix Makefile

* fix Makefile

* fix merge conflicts

* Fix CI test workflow

Similar to Skywire main repo, we need to bump the Go version to continue
using the action for installing Go in CI.

* Bump base image Go version for Go

* Vendor

* fix transport setup keys missing on dmsg-monitor and network-monitor reading config

* change reading config logic of vpn-monitor and public-visor-monitor

* upgrade golangci-lint to 1.52.1

* upgrade golang:alpine to 3.19

* upgrade golang:alpine to 3.17

* update dmsg for use dmsgcurl instead dmsgget

* update dmsg and skywire at develop | go mod tidy | go mod vendor

* update go to 1.21.*

* update go in docker build to 1.21

* update config-bootstrapper Dockerfile

* tiny dummy update on config-bootstrapper for checking issue

* tiny dummy update on config-bootstrapper for checking issue 2

* fix .test workflow

* add changes for test

* do tiny changes on docker_build.sh script

* update skywire-utilities

* update skywier@develop

* update skywire and dmsg @ develop

* update skywire-utilities

* upgrade golang to 1.21

* fix visor configs

* improve `/health` endpoint informations (#33)

* add --sk to services for available dmsghttp during e2e and integration env test

* update dmsg@develp

* add dmsg_servers to AR health endpoint

* add dmsg_servers to RF health endpoint

* add dmsg_servers to TPD health endpoint

* update go to 1.21 for dmsg-discovery and dmsg-server on integration env

* fix docker-compose.yml file for dmsg-disc address on services for integration test

* add dmsghttp access (#34)

* Update dependencies (#37)

* update skywire,dmsg, and skywire-utilities

* upgrade golangci-lint to v1.55.2

* fix version of visor config on docker configs

* change golang version on skywire-visor Dockerfile to golang:1.21-alpine

* upgrade skywire to v1.3.16

* fix wrong url on tpd deregister

* fix typo

* improve error log on tpd monitor

* move deregister endpoint out of nonce needed scope

* add whitelisted pks to tpd

* fix linting issue

* add shuffle on entries list of dmsg monitor

* fix shuffle comment

* revert to old vpn-lite-client implementation

* change oldApps logic on read config on vpn-monitor | remove unnecessary codes

* add shuffle on vpn list

* fix route setup pks

* add tpsetuppks and surveywhitelistpks

* Skysocks Monitor (#47)

* implement skysocks-lite-client

* create dockerfile

* implement skysocks-monitor

* update docker build/push to dockerhub commands for skysocks-monitor

* add dummy skysocks-monitor config on docker configs

* modify Makefile

* fix wrong api path

* update ascii of cli app

* fix typo and name issue on tpd monitor"

* fix errors condition

* fix make check errors

* update docker-compose config

* udpate docker configs

* fix some little issues

* revert changes on dockerfiles

* fix little issues

* fix vpn-test after recent changes on skywire vpn commands

* fix sd address for test

* fix sd address for test 2

* fix ut address for test

* disable skywire-cli vpn list command tests

* downgrade wireguard

* fix VisorTpRm test command

* upgrade skywire-utilities@develop

* add reward system pks to dmsg monitor whitelisted keys

* disable node visualizer on docker build/push/clean steps, temporary

* update dmsg@develop skywire@develop

* - increase gap between two deregistation from 10 to 60 minutes
- use visorEntries endpoint on dmsg-monitor process, instead all entries (include dmsgweb, dmsghttp and etc.)

* update skywire-utilities@develop"

* update configs of integraion and e2e tests

* update visor config file on e2e-test

* fix visor configs on integration/e2e test

* fix visors configs

* add nocash to create e2e-image of visor"

* revert cash on dockerfile skywire visors

* minor cli interface refactor (#53)

* move coloredcobra initialization to command wrapper

* fix ci errors

* update dmsg to latest commit on develop

* fix skymessage ci issue

* update skywire@develop

* add skysocks-monitor to e2e

* fix skysock monitor issue on e2e

* Improve help menus (#54)

* add dependencies and setup instructions for core services to help menus

* update vendor deps

* delete syslog from whole of the repo

* fix ar issue on help menu

* add newTUNDevice to windows

* move back UT from own repo here

* udpate db config for other services like UT

* fix tidy & vendor

* update skywire dockerfile and configs

* update skywire dockerfile and configs 2

* remove wrong commands

* fix ut docker file

* fix ENTRYPOINT of skywire

* fix docker compose command

* fix env_test commands

* update visor configs

* update visor configs 2

* update skywire@develop

* upgrade dsmg to v1.3.20

* CLI for transport setup node (#65)

* cli interface for transport setup node
* fix Makefile ; make format

---------

Co-authored-by: Mohammed <[email protected]>
Co-authored-by: Moses Narrow <[email protected]>
Co-authored-by: Mohammed <[email protected]>
  • Loading branch information
4 people authored Apr 11, 2024
1 parent 3f228fa commit 35e18dc
Show file tree
Hide file tree
Showing 2,128 changed files with 484,734 additions and 205,922 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ jobs:
- name: Setup golang
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.21.x
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Requirements
run: |
GO111MODULES=off; go mod vendor
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
- name: Setup SSH Key Build and run e2e
run : |
make e2e-build
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ linters:
- megacheck
- misspell
- nakedret
- depguard
enable-all: false
disable:
disable-all: true
Expand Down
79 changes: 17 additions & 62 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DATE := $(shell date -u $(RFC_3339))
COMMIT := $(shell git rev-list -1 HEAD)

OPTS?=GO111MODULE=on
DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container
DOCKER_OPTS?=GO111MODULE=on GOOS=linux
DOCKER_NETWORK?=SKYWIRE
DOCKER_COMPOSE_FILE:=./docker/docker-compose.yml
DOCKER_REGISTRY:=skycoin
Expand Down Expand Up @@ -45,78 +45,32 @@ export REGISTRY=${DOCKER_REGISTRY}
## : ## _ [Prepare code]

dep: ## Sorts dependencies
@command -v yarn >/dev/null 2>&1 && yarn --cwd ./pkg/node-visualizer/web install || true
# GO111MODULE=on GOPRIVATE=github.com/skycoin/* go get -v github.com/skycoin/skywire@master
GO111MODULE=on GOPRIVATE=github.com/skycoin/* go mod vendor -v
yarn --cwd ./pkg/node-visualizer/web install
# GO111MODULE=on GOPRIVATE=github.com/skycoin/* go mod vendor -v

format: dep ## Formats the code. Must have goimports and goimports-reviser installed (use make install-linters).
goimports -w -local github.com/skycoin/skywire-services ./pkg
goimports -w -local github.com/skycoin/skywire-services ./cmd
goimports -w -local github.com/skycoin/skywire-services ./internal
find . -type f -name '*.go' -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} {} \;
goimports -w -local github.com/skycoin/skywire-services ./pkg ./cmd ./internal
find . -type f -name '*.go' -not -path "./.git/*" -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} {} \;

## : ## _ [Build, install, clean]

build: dep ## Build binaries
${OPTS} go build ${BUILD_OPTS} -o ./bin/route-finder ./cmd/route-finder
${OPTS} go build ${BUILD_OPTS} -o ./bin/setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -o ./bin/transport-discovery ./cmd/transport-discovery
${OPTS} go build ${BUILD_OPTS} -o ./bin/address-resolver ./cmd/address-resolver
${OPTS} go build ${BUILD_OPTS} -o ./bin/sw-env ./cmd/sw-env
${OPTS} go build ${BUILD_OPTS} -o ./bin/keys-gen ./cmd/keys-gen
${OPTS} go build ${BUILD_OPTS} -o ./bin/network-monitor ./cmd/network-monitor
${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-client ./cmd/vpn-lite-client
${OPTS} go build ${BUILD_OPTS} -o ./bin/transport-setup ./cmd/transport-setup
${OPTS} go build ${BUILD_OPTS} -o ./bin/config-bootstrapper ./cmd/config-bootstrapper
${OPTS} go build ${BUILD_OPTS} -o ./bin/liveness-checker ./cmd/liveness-checker
${OPTS} go build ${BUILD_OPTS} -o ./bin/dmsg-monitor ./cmd/dmsg-monitor
${OPTS} go build ${BUILD_OPTS} -o ./bin/tpd-monitor ./cmd/tpd-monitor
${OPTS} go build ${BUILD_OPTS} -o ./bin/vpn-monitor ./cmd/vpn-monitor
${OPTS} go build ${BUILD_OPTS} -o ./bin/public-visor-monitor ./cmd/public-visor-monitor
${OPTS} go build ${BUILD_OPTS} -o ./bin/skywire-services ./cmd/skywire-services

# yarn --cwd ./pkg/node-visualizer/web build
# rm -rf ./pkg/node-visualizer/api/build/static
# mv ./pkg/node-visualizer/web/build/* ./pkg/node-visualizer/api/build
# ${OPTS} go build ${BUILD_OPTS} -o ./bin/node-visualizer ./cmd/node-visualizer

build-deploy: ## Build for deployment Docker images
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/address-resolver ./cmd/address-resolver
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/route-finder ./cmd/route-finder
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/setup-node ./cmd/setup-node
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/transport-discovery ./cmd/transport-discovery
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/network-monitor ./cmd/network-monitor
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/vpn-client ./cmd/vpn-lite-client
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/transport-setup ./cmd/transport-setup
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/node-visualizer ./cmd/node-visualizer
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/dmsg-monitor ./cmd/dmsg-monitor
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/tpd-monitor ./cmd/tpd-monitor
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/vpn-monitor ./cmd/vpn-monitor
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/public-visor-monitor ./cmd/public-visor-monitor
${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/skywire-services ./cmd/skywire-services

build-race: dep ## Build binaries
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/route-finder ./cmd/route-finder
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/transport-discovery ./cmd/transport-discovery
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/address-resolver ./cmd/address-resolver
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/sw-env ./cmd/sw-env
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/keys-gen ./cmd/keys-gen
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/network-monitor ./cmd/network-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/vpn-client ./cmd/vpn-lite-client
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/transport-setup ./cmd/transport-setup
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/node-visualizer ./cmd/node-visualizer
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/dmsg-monitor ./cmd/dmsg-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/tpd-monitor ./cmd/tpd-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/vpn-monitor ./cmd/vpn-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/public-visor-monitor ./cmd/public-visor-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/skywire-services ./cmd/skywire-services

install: ## Install route-finder, transport-discovery, address-resolver, sw-env, keys-gen, network-monitor, node-visualizer
${OPTS} go install ${BUILD_OPTS} \
./cmd/route-finder \
./cmd/transport-discovery \
./cmd/address-resolver \
./cmd/sw-env \
./cmd/keys-gen \
./cmd/network-monitor \
./cmd/node-visualizer
${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-services

clean: ## Clean compiled binaries
rm -rf bin
Expand Down Expand Up @@ -188,9 +142,15 @@ e2e-help: ## E2E. Show env-vars and useful commands
@echo -e " docker-compose up/down/start/stop"
@echo -e "\nConsult with:\n\n docker-compose help\n"

docker-build-test:
bash ./docker/docker_build.sh test ${BUILD_OPTS_DEPLOY}

docker-build:
bash ./docker/docker_build.sh prod ${BUILD_OPTS_DEPLOY}

docker-push-test:
bash ./docker/docker_build.sh test ${BUILD_OPTS_DEPLOY}
# bash ./docker/docker_push.sh test
bash ./docker/docker_push.sh test

docker-push:
bash ./docker/docker_build.sh prod ${BUILD_OPTS_DEPLOY}
Expand Down Expand Up @@ -236,10 +196,5 @@ vendor-integration-check: ## Check compatibility of master@skywire-services with

## : ## _ [Other]

run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog
-mkdir -p /tmp/syslog
-docker container rm syslog-ng -f
docker run -d -p 514:514/udp -v /tmp/syslog:/var/log --name syslog-ng balabit/syslog-ng:latest

help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$|^##.*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Setup Node (SN)
- Service Discovery (SD)
- Address Resolver (AR)
- Uptime Tracker (UT)

## Running the services locally

Expand Down Expand Up @@ -71,3 +72,4 @@ Check the [docs](docs/Deployments.md) for more documentation on the deployments.
- [Dmsg Discovery](https://github.com/skycoin/dmsg/blob/develop/cmd/dmsg-discovery/README.md)
- [Dmsg Server](https://github.com/skycoin/dmsg/blob/develop/cmd/dmsg-server/README.md)
- [Service Discovery](https://github.com/skycoin/skycoin-service-discovery/blob/master/README.md#http-api)
- [Uptime Tracker](cmd/uptime-tracker/README.md)
31 changes: 31 additions & 0 deletions cmd/address-resolver/address-resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,40 @@
package main

import (
cc "github.com/ivanpirog/coloredcobra"
"github.com/spf13/cobra"

"github.com/skycoin/skywire-services/cmd/address-resolver/commands"
)

func init() {
commands.RootCmd.SetUsageTemplate(help)
commands.RootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
commands.RootCmd.PersistentFlags().MarkHidden("help") //nolint
}

func main() {
cc.Init(&cc.Config{
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
})
commands.Execute()
}

const help = "Usage:\r\n" +
" {{.UseLine}}{{if .HasAvailableSubCommands}}{{end}} {{if gt (len .Aliases) 0}}\r\n\r\n" +
"{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}\r\n\r\n" +
"Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand)}}\r\n " +
"{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}\r\n\r\n" +
"Flags:\r\n" +
"{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}\r\n\r\n" +
"Global Flags:\r\n" +
"{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}\r\n\r\n"
75 changes: 41 additions & 34 deletions cmd/address-resolver/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

cc "github.com/ivanpirog/coloredcobra"
logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/dmsg/pkg/direct"
"github.com/skycoin/dmsg/pkg/dmsg"
"github.com/skycoin/dmsg/pkg/dmsghttp"
Expand Down Expand Up @@ -41,7 +41,6 @@ var (
metricsAddr string
redisURL string
redisPoolSize int
syslogAddr string
tag string
logLvl string
testing bool
Expand All @@ -53,33 +52,42 @@ var (
)

func init() {
rootCmd.Flags().StringVarP(&addr, "addr", "a", ":9093", "address to bind to\033[0m")
rootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", "", "address to bind metrics API to\033[0m")
rootCmd.Flags().StringVar(&redisURL, "redis", "redis://localhost:6379", "connections string for a redis store\033[0m")
rootCmd.Flags().IntVar(&redisPoolSize, "redis-pool-size", 10, "redis connection pool size\033[0m")
rootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
rootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
rootCmd.Flags().StringVar(&tag, "tag", "address_resolver", "logging tag\033[0m")
rootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
rootCmd.Flags().StringVar(&dmsgDisc, "dmsg-disc", "http://dmsgd.skywire.skycoin.com", "url of dmsg-discovery\033[0m")
rootCmd.Flags().StringVar(&whitelistKeys, "whitelist-keys", "", "list of whitelisted keys of network monitor used for deregistration\033[0m")
rootCmd.Flags().BoolVar(&testEnvironment, "test-environment", false, "distinguished between prod and test environment\033[0m")
rootCmd.Flags().Var(&sk, "sk", "dmsg secret key\r")
rootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\r")
RootCmd.Flags().StringVarP(&addr, "addr", "a", ":9093", "address to bind to\033[0m")
RootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", "", "address to bind metrics API to\033[0m")
RootCmd.Flags().StringVar(&redisURL, "redis", "redis://localhost:6379", "connections string for a redis store\033[0m")
RootCmd.Flags().IntVar(&redisPoolSize, "redis-pool-size", 10, "redis connection pool size\033[0m")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
RootCmd.Flags().StringVar(&tag, "tag", "address_resolver", "logging tag\033[0m")
RootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
RootCmd.Flags().StringVar(&dmsgDisc, "dmsg-disc", "http://dmsgd.skywire.skycoin.com", "url of dmsg-discovery\033[0m")
RootCmd.Flags().StringVar(&whitelistKeys, "whitelist-keys", "", "list of whitelisted keys of network monitor used for deregistration\033[0m")
RootCmd.Flags().BoolVar(&testEnvironment, "test-environment", false, "distinguished between prod and test environment\033[0m")
RootCmd.Flags().Var(&sk, "sk", "dmsg secret key\r")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\r")
var helpflag bool
rootCmd.SetUsageTemplate(help)
rootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for "+rootCmd.Use)
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
rootCmd.PersistentFlags().MarkHidden("help") //nolint
RootCmd.SetUsageTemplate(help)
RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for address-resolver")
RootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
RootCmd.PersistentFlags().MarkHidden("help") //nolint
}

var rootCmd = &cobra.Command{
Use: "address-resolver",
// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Address Resolver Server for skywire",
Long: `
┌─┐┌┬┐┌┬┐┬─┐┌─┐┌─┐┌─┐ ┬─┐┌─┐┌─┐┌─┐┬ ┬ ┬┌─┐┬─┐
├─┤ ││ ││├┬┘├┤ └─┐└─┐───├┬┘├┤ └─┐│ ││ └┐┌┘├┤ ├┬┘
┴ ┴─┴┘─┴┘┴└─└─┘└─┘└─┘ ┴└─└─┘└─┘└─┘┴─┘└┘ └─┘┴└─`,
┴ ┴─┴┘─┴┘┴└─└─┘└─┘└─┘ ┴└─└─┘└─┘└─┘┴─┘└┘ └─┘┴└─
depends: redis
Note: the specified port must be accessible from the internet ip address or port forwarded for udp
skywire cli config gen-keys > ar-config.json
skywire svc ar --addr ":9093" --redis "redis://localhost:6379" --sk $(tail -n1 ar-config.json)
`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down Expand Up @@ -145,14 +153,6 @@ var rootCmd = &cobra.Command{
logger.WithError(err).Warn("No SecKey found. Skipping serving on dmsghttp.")
}

if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil && logger != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

metricsutil.ServeHTTPMetrics(logger, metricsAddr)

var m armetrics.Metrics
Expand Down Expand Up @@ -206,10 +206,17 @@ var rootCmd = &cobra.Command{

defer closeDmsgDC()

go func() {
for {
arAPI.DmsgServers = dmsgDC.ConnectedServersPK()
time.Sleep(time.Second)
}
}()

go dmsghttp.UpdateServers(ctx, dClient, dmsgDisc, dmsgDC, logger)

go func() {
if err := dmsghttp.ListenAndServe(ctx, pk, sk, arAPI, dClient, dmsg.DefaultDmsgHTTPPort, config, dmsgDC, logger); err != nil {
if err := dmsghttp.ListenAndServe(ctx, sk, arAPI, dClient, dmsg.DefaultDmsgHTTPPort, dmsgDC, logger); err != nil {
logger.Errorf("dmsghttp.ListenAndServe: %v", err)
cancel()
}
Expand All @@ -225,7 +232,7 @@ var rootCmd = &cobra.Command{
// Execute executes root CLI command.
func Execute() {
cc.Init(&cc.Config{
RootCmd: rootCmd,
RootCmd: RootCmd,
Headings: cc.HiBlue + cc.Bold, //+ cc.Underline,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Expand All @@ -237,7 +244,7 @@ func Execute() {
NoExtraNewlines: true,
NoBottomNewline: true,
})
if err := rootCmd.Execute(); err != nil {
if err := RootCmd.Execute(); err != nil {
log.Fatal("Failed to execute command: ", err)

}
Expand Down
Loading

0 comments on commit 35e18dc

Please sign in to comment.