mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-27 12:25:55 +03:00
Added flag to specify config file location
This commit is contained in:
parent
db1adcac97
commit
04162aaa79
2 changed files with 12 additions and 1 deletions
11
main.go
11
main.go
|
@ -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
|
||||
|
|
|
@ -174,3 +174,5 @@ func enableLogging(l config.Log) (*log.Logger, error) {
|
|||
|
||||
return log.New(file, "", 0), nil
|
||||
}
|
||||
|
||||
const DefaultConfigFile = "Caddyfile"
|
||||
|
|
Loading…
Reference in a new issue