summaryrefslogtreecommitdiffhomepage
path: root/caddy.go
diff options
context:
space:
mode:
authorMiek Gieben <[email protected]>2016-08-19 00:19:45 +0000
committerMiek Gieben <[email protected]>2016-08-19 00:19:45 +0000
commita609fa5f563be2837d7dbce59f1fc634402a0f9a (patch)
tree21919917efd9c462cf8a18f2c1c5633cbd81752b /caddy.go
parentfdc62d015fd5c20e03143e2eea17528892270169 (diff)
downloadcaddy-a609fa5f563be2837d7dbce59f1fc634402a0f9a.tar.gz
caddy-a609fa5f563be2837d7dbce59f1fc634402a0f9a.zip
Implement missing bits for an external servertype
Make ServerListeners public and add two helper methods to get access to the address they listen on. This is useful for tests (among other things) Also make DefaultConfigFile a var so it can be overridden by server types.
Diffstat (limited to 'caddy.go')
-rw-r--r--caddy.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/caddy.go b/caddy.go
index ff578d12b..b0ec1af66 100644
--- a/caddy.go
+++ b/caddy.go
@@ -76,7 +76,7 @@ type Instance struct {
context Context
// servers is the list of servers with their listeners.
- servers []serverListener
+ servers []ServerListener
// these callbacks execute when certain events occur
onFirstStartup []func() error // starting, not as part of a restart
@@ -86,6 +86,9 @@ type Instance struct {
onFinalShutdown []func() error // stopping, not as part of a restart
}
+// Servers returns the ServerListeners in i.
+func (i *Instance) Servers() []ServerListener { return i.servers }
+
// Stop stops all servers contained in i. It does NOT
// execute shutdown callbacks.
func (i *Instance) Stop() error {
@@ -202,7 +205,7 @@ func (i *Instance) Restart(newCaddyfile Input) (*Instance, error) {
// internally-kept list of servers that is running. For
// saved servers, graceful restarts will be provided.
func (i *Instance) SaveServer(s Server, ln net.Listener) {
- i.servers = append(i.servers, serverListener{server: s, listener: ln})
+ i.servers = append(i.servers, ServerListener{server: s, listener: ln})
}
// HasListenerWithAddress returns whether this package is
@@ -644,7 +647,7 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res
errChan <- s.ServePacket(pc)
}(s, ln, pc, inst)
- inst.servers = append(inst.servers, serverListener{server: s, listener: ln, packet: pc})
+ inst.servers = append(inst.servers, ServerListener{server: s, listener: ln, packet: pc})
}
// Log errors that may be returned from Serve() calls,
@@ -836,7 +839,7 @@ var (
instancesMu sync.Mutex
)
-const (
+var (
// DefaultConfigFile is the name of the configuration file that is loaded
// by default if no other file is specified.
DefaultConfigFile = "Caddyfile"