Commit 437b212e authored by Sietse Ringers's avatar Sietse Ringers Committed by Ivar Derksen
Browse files

feat: check existence of server configuration file, if specified

parent d6cf7ff0
......@@ -93,6 +93,17 @@ func readConfig(cmd *cobra.Command, name, logname string, configpaths []string,
// Locate and read configuration file
confpath := viper.GetString("config")
if confpath != "" {
info, err := os.Stat(confpath)
if err != nil {
if os.IsNotExist(err) {
die("specified configuration file does not exist", nil)
} else {
die("failed to stat configuration file", err)
if info.IsDir() {
die("specified configuration file is a directory", nil)
dir, file := filepath.Dir(confpath), filepath.Base(confpath)
viper.SetConfigName(strings.TrimSuffix(file, filepath.Ext(file)))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment