Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
26bb1733
Commit
26bb1733
authored
May 20, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Warn if ulimit is too low when serving production sites
parent
5e8491cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
4 deletions
+20
-4
main.go
main.go
+20
-4
No files found.
main.go
View file @
26bb1733
...
...
@@ -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
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment