Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • project_setup default protected
  • bindings-update
  • xxclient
  • development
5 results

README.md

Blame
  • root.go 7.41 KiB
    ////////////////////////////////////////////////////////////////////////////////
    // Copyright © 2020 Privategrity Corporation                                   /
    //                                                                             /
    // All rights reserved.                                                        /
    ////////////////////////////////////////////////////////////////////////////////
    
    // Package cmd initializes the CLI and config parsers as well as the logger
    
    package cmd
    
    import (
    	"fmt"
    	"github.com/mitchellh/go-homedir"
    	"github.com/pkg/errors"
    	"github.com/spf13/cobra"
    	jww "github.com/spf13/jwalterweatherman"
    	"github.com/spf13/viper"
    	"gitlab.com/elixxir/comms/mixmessages"
    	"gitlab.com/elixxir/notifications-bot/notifications"
    	"gitlab.com/elixxir/notifications-bot/storage"
    	"gitlab.com/elixxir/primitives/id"
    	"gitlab.com/elixxir/primitives/ndf"
    	"gitlab.com/elixxir/primitives/utils"
    	"os"
    	"path"
    	"strings"
    )
    
    var (
    	cfgFile            string
    	verbose            bool
    	noTLS              bool
    	NotificationParams notifications.Params
    	loopDelay          int
    )
    
    // rootCmd represents the base command when called without any subcommands
    var rootCmd = &cobra.Command{
    	Use:   "registration",
    	Short: "Runs a registration server for cMix",
    	Long:  `This server provides registration functions on cMix`,
    	Args:  cobra.NoArgs,
    	Run: func(cmd *cobra.Command, args []string) {
    		if verbose {
    			err := os.Setenv("GRPC_GO_LOG_SEVERITY_LEVEL", "info")
    			if err != nil {
    				jww.ERROR.Printf("Could not set GRPC_GO_LOG_SEVERITY_LEVEL: %+v", err)
    			}
    
    			err = os.Setenv("GRPC_GO_LOG_VERBOSITY_LEVEL", "2")
    			if err != nil {
    				jww.ERROR.Printf("Could not set GRPC_GO_LOG_VERBOSITY_LEVEL: %+v", err)
    			}
    		}
    
    		// Parse config file options
    		certPath := viper.GetString("certPath")
    		keyPath := viper.GetString("keyPath")
    		localAddress := fmt.Sprintf("0.0.0.0:%d", viper.GetInt("port"))
    		fbCreds := viper.GetString("firebaseCredentialsPath")
    
    		// Populate params
    		NotificationParams = notifications.Params{
    			Address:  localAddress,
    			CertPath: certPath,
    			KeyPath:  keyPath,
    			FBCreds:  fbCreds,
    		}
    		jww.INFO.Println("Starting Notifications...")