github.com/resonatecoop/id@v1.1.0-43/cmd/util.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/resonatecoop/id/config"
     5  	"github.com/resonatecoop/id/database"
     6  
     7  	//	"github.com/resonatecoop/id/database"
     8  	"github.com/uptrace/bun"
     9  )
    10  
    11  // initConfigDB loads the configuration and connects to the database
    12  func initConfigDB(mustLoadOnce, keepReloading bool, configBackend string) (*config.Config, *bun.DB, error) {
    13  	// Config
    14  	cnf := config.NewConfig(mustLoadOnce, keepReloading, configBackend)
    15  
    16  	// Database
    17  	db, err := database.NewDatabase(cnf)
    18  	if err != nil {
    19  		return nil, nil, err
    20  	}
    21  
    22  	return cnf, db, nil
    23  }