Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
cmd: Make --config flag optional for reload command
In case it is using the default Caddyfile
Matthew Holt committed
Jan 22, 2020 at 09:33 UTC
9a1370c2c8fb2c52585971d9eaa6f0c4383cb869
2 files changed
+2
-8
cmd/commandfuncs.go
+1
-7
@@ -264,12 +264,6 @@ func cmdReload(fl Flags) (int, error) {
264
reloadCmdConfigAdapterFlag := fl.String("adapter")
265
reloadCmdAddrFlag := fl.String("address")
266
267
- // a configuration is required
268
- if reloadCmdConfigFlag == "" {
269
- return caddy.ExitCodeFailedStartup,
270
- fmt.Errorf("no configuration to load (use --config)")
271
- }
272
-
267
// get the config in caddy's native format
268
config, err := loadConfig(reloadCmdConfigFlag, reloadCmdConfigAdapterFlag)
269
if err != nil {
@@ -278,7 +272,7 @@ func cmdReload(fl Flags) (int, error) {
272
273
// get the address of the admin listener and craft endpoint URL
274
adminAddr := reloadCmdAddrFlag
281
- if adminAddr == "" {
275
+ if adminAddr == "" && len(config) > 0 {
276
var tmpStruct struct {
277
Admin caddy.AdminConfig `json:"admin"`
278
}
cmd/main.go
+1
-1
@@ -97,7 +97,7 @@ func handlePingbackConn(conn net.Conn, expect []byte) error {
97
// the resulting JSON config bytes.
98
func loadConfig(configFile, adapterName string) ([]byte, error) {
99
// specifying an adapter without a config file is ambiguous
100
- if configFile == "" && adapterName != "" {
100
+ if adapterName != "" && configFile == "" {
101
return nil, fmt.Errorf("cannot adapt config without config file (use --config)")
102
}
103