Commit 26bb1733 authored by Matthew Holt's avatar Matthew Holt

Warn if ulimit is too low when serving production sites

parent 5e8491cf
......@@ -9,6 +9,7 @@ import (
"log"
"net"
"os"
"os/exec"
"path"
"runtime"
"strconv"
......@@ -86,17 +87,32 @@ func main() {
}(s)
if !quiet {
for _, config := range configs {
fmt.Println(config.Address())
}
var checkedFdLimit bool
for addr, configs := range addresses {
for _, conf := range configs {
// Print address of site
fmt.Println(conf.Address())
// Note if non-localhost site resolves to loopback interface
if addr.IP.IsLoopback() && !isLocalhost(conf.Host) {
fmt.Printf("Notice: %s is only accessible on this machine (%s)\n",
conf.Host, addr.IP.String())
}
}
// Warn if ulimit is too low for production sites
if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") &&
addr.IP.IsLoopback() && !checkedFdLimit {
out, err := exec.Command("ulimit", "-n").Output()
if err == nil {
// Note that an error here need not be reported
lim, err := strconv.Atoi(string(bytes.TrimSpace(out)))
if err == nil && lim < 4096 {
fmt.Printf("Warning: File descriptor limit is too low (%d) for production sites\n", lim)
}
checkedFdLimit = true
}
}
}
}
}
......
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