diff --git a/cmd/dmsg-server/commands/root.go b/cmd/dmsg-server/commands/root.go deleted file mode 100644 index 521da5096..000000000 --- a/cmd/dmsg-server/commands/root.go +++ /dev/null @@ -1,119 +0,0 @@ -package commands - -import ( - "bufio" - "encoding/json" - "io" - "log" - "log/syslog" - "net" - "net/http" - "os" - "path/filepath" - - "github.com/SkycoinProject/dmsg" - "github.com/SkycoinProject/dmsg/cipher" - "github.com/SkycoinProject/dmsg/disc" - "github.com/SkycoinProject/skycoin/src/util/logging" - "github.com/prometheus/client_golang/prometheus/promhttp" - logrussyslog "github.com/sirupsen/logrus/hooks/syslog" - "github.com/spf13/cobra" -) - -var ( - metricsAddr string - syslogAddr string - tag string - cfgFromStdin bool -) - -// Config is a messaging-server config -type Config struct { - PubKey cipher.PubKey `json:"public_key"` - SecKey cipher.SecKey `json:"secret_key"` - Discovery string `json:"discovery"` - LocalAddress string `json:"local_address"` - PublicAddress string `json:"public_address"` - LogLevel string `json:"log_level"` -} - -var rootCmd = &cobra.Command{ - Use: "messaging-server [config.json]", - Short: "Messaging Server for skywire", - Run: func(_ *cobra.Command, args []string) { - // Config - configFile := "config.json" - if len(args) > 0 { - configFile = args[0] - } - conf := parseConfig(configFile) - - // Logger - logger := logging.MustGetLogger(tag) - logLevel, err := logging.LevelFromString(conf.LogLevel) - if err != nil { - log.Fatal("Failed to parse LogLevel: ", err) - } - logging.SetLevel(logLevel) - - if syslogAddr != "" { - hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag) - if err != nil { - logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr) - } - logging.AddHook(hook) - } - - // Metrics - go func() { - http.Handle("/metrics", promhttp.Handler()) - if err := http.ListenAndServe(metricsAddr, nil); err != nil { - logger.Println("Failed to start metrics API:", err) - } - }() - - l, err := net.Listen("tcp", conf.LocalAddress) - if err != nil { - logger.Fatalf("Error listening on %s: %v", conf.LocalAddress, err) - } - - // Start - srv := dmsg.NewServer(conf.PubKey, conf.SecKey, disc.NewHTTP(conf.Discovery)) - - log.Fatal(srv.Serve(l, conf.PublicAddress)) - }, -} - -func init() { - rootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", ":2121", "address to bind metrics API to") - rootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514") - rootCmd.Flags().StringVar(&tag, "tag", "messaging-server", "logging tag") - rootCmd.Flags().BoolVarP(&cfgFromStdin, "stdin", "i", false, "read configuration from STDIN") -} - -func parseConfig(configFile string) *Config { - var rdr io.Reader - var err error - if !cfgFromStdin { - rdr, err = os.Open(filepath.Clean(configFile)) - if err != nil { - log.Fatalf("Failed to open config: %s", err) - } - } else { - rdr = bufio.NewReader(os.Stdin) - } - - conf := &Config{} - if err := json.NewDecoder(rdr).Decode(&conf); err != nil { - log.Fatalf("Failed to decode %s: %s", rdr, err) - } - - return conf -} - -// Execute executes root CLI command. -func Execute() { - if err := rootCmd.Execute(); err != nil { - log.Fatal(err) - } -} diff --git a/cmd/dmsg-server/dmsg-server.go b/cmd/dmsg-server/dmsg-server.go deleted file mode 100644 index c0cabf78c..000000000 --- a/cmd/dmsg-server/dmsg-server.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "github.com/SkycoinProject/skywire-mainnet/cmd/dmsg-server/commands" - -func main() { - commands.Execute() -} diff --git a/pkg/router/route_group.go b/pkg/router/route_group.go index d3bea35be..1bfa0b9d8 100644 --- a/pkg/router/route_group.go +++ b/pkg/router/route_group.go @@ -21,7 +21,7 @@ import ( const ( defaultRouteGroupKeepAliveInterval = 1 * time.Minute - defaultRouteGroupIOTimeout = 3 * time.Second + defaultRouteGroupIOTimeout = 300 * time.Second defaultReadChBufSize = 1024 )