Commit 04162aaa authored by Matthew Holt's avatar Matthew Holt

Added flag to specify config file location

parent db1adcac
package main package main
import ( import (
"flag"
"log" "log"
"sync" "sync"
...@@ -11,7 +12,9 @@ import ( ...@@ -11,7 +12,9 @@ import (
func main() { func main() {
var wg sync.WaitGroup var wg sync.WaitGroup
vhosts, err := config.Load("Caddyfile") flag.Parse()
vhosts, err := config.Load(conf)
if err != nil { if err != nil {
if config.IsNotFound(err) { if config.IsNotFound(err) {
vhosts = config.Default() vhosts = config.Default()
...@@ -37,3 +40,9 @@ func main() { ...@@ -37,3 +40,9 @@ func main() {
wg.Wait() wg.Wait()
} }
func init() {
flag.StringVar(&conf, "conf", server.DefaultConfigFile, "the configuration file to use")
}
var conf string
...@@ -174,3 +174,5 @@ func enableLogging(l config.Log) (*log.Logger, error) { ...@@ -174,3 +174,5 @@ func enableLogging(l config.Log) (*log.Logger, error) {
return log.New(file, "", 0), nil return log.New(file, "", 0), nil
} }
const DefaultConfigFile = "Caddyfile"
Markdown is supported
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