leo
9ab2d0ae0b
* add log messages telling the user what went wrong if the app fails to start * improve existing log messages * cleanup: close channels when exiting * cleanup: stop listening for signals when exiting
30 lines
556 B
Go
30 lines
556 B
Go
package config
|
|
|
|
import (
|
|
"git.dotya.ml/mirre-mt/pcmt/slogging"
|
|
"github.com/philandstuff/dhall-golang/v6"
|
|
)
|
|
|
|
type Config struct {
|
|
Host string
|
|
Port int
|
|
AppName string
|
|
LiveMode bool
|
|
DevelMode bool
|
|
SessionCookieName string
|
|
SessionCookieSecret string
|
|
}
|
|
|
|
func LoadConfig(path string) (*Config, error) {
|
|
var config Config
|
|
|
|
err := dhall.UnmarshalFile(path, &config)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
slogging.GetLogger().Debugf("parsed config: %+v", config)
|
|
|
|
return &config, nil
|
|
}
|