Added flag to specify config file location

This commit is contained in:
Matthew Holt 2015-01-13 16:14:00 -07:00
parent db1adcac97
commit 04162aaa79
2 changed files with 12 additions and 1 deletions

11
main.go
View file

@ -1,6 +1,7 @@
package main
import (
"flag"
"log"
"sync"
@ -11,7 +12,9 @@ import (
func main() {
var wg sync.WaitGroup
vhosts, err := config.Load("Caddyfile")
flag.Parse()
vhosts, err := config.Load(conf)
if err != nil {
if config.IsNotFound(err) {
vhosts = config.Default()
@ -37,3 +40,9 @@ func main() {
wg.Wait()
}
func init() {
flag.StringVar(&conf, "conf", server.DefaultConfigFile, "the configuration file to use")
}
var conf string

View file

@ -174,3 +174,5 @@ func enableLogging(l config.Log) (*log.Logger, error) {
return log.New(file, "", 0), nil
}
const DefaultConfigFile = "Caddyfile"