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
Łukasz Nowak
caddy
Commits
04fd7ce9
Commit
04fd7ce9
authored
9 years ago
by
Joshua Poehls
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated ulimit warning message to include the recommended min value.
parent
cc958947
master
nxd-v0.11.0
nxd-v0.11.0-plugins
v0.11.0
v0.10.14
v0.10.13
v0.10.12
v0.10.11
v0.10.10
v0.10.9
v0.10.8
v0.10.7
v0.10.6
v0.10.5
v0.10.4
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.5
v0.9.4
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.9-beta.2
v0.9-beta.1
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.8-beta.4
v0.8-beta.3
v0.8-beta.2
v0.8-beta.1
v0.7.6
v0.7.5
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
nxd-v0.11.0-3-g12438f6cff8c15f307631151eb064cec579b7605
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
main.go
main.go
+20
-12
No files found.
main.go
View file @
04fd7ce9
...
...
@@ -95,18 +95,9 @@ func main() {
}
}
// Warn if ulimit is too low for production sites
if
(
runtime
.
GOOS
==
"linux"
||
runtime
.
GOOS
==
"darwin"
)
&&
!
addr
.
IP
.
IsLoopback
()
&&
!
checkedFdLimit
{
out
,
err
:=
exec
.
Command
(
"sh"
,
"-c"
,
"ulimit -n"
)
.
Output
()
// use sh because ulimit isn't in Linux $PATH
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
}
if
!
checkedFdLimit
&&
!
addr
.
IP
.
IsLoopback
()
{
checkFdlimit
()
checkedFdLimit
=
true
}
}
}
...
...
@@ -115,6 +106,23 @@ func main() {
app
.
Wg
.
Wait
()
}
// checkFdlimit issues a warning if the OS max file descriptors is below a recommended minimum.
func
checkFdlimit
()
{
const
min
=
4096
// Warn if ulimit is too low for production sites
if
runtime
.
GOOS
==
"linux"
||
runtime
.
GOOS
==
"darwin"
{
out
,
err
:=
exec
.
Command
(
"sh"
,
"-c"
,
"ulimit -n"
)
.
Output
()
// use sh because ulimit isn't in Linux $PATH
if
err
==
nil
{
// Note that an error here need not be reported
lim
,
err
:=
strconv
.
Atoi
(
string
(
bytes
.
TrimSpace
(
out
)))
if
err
==
nil
&&
lim
<
min
{
fmt
.
Printf
(
"Warning: File descriptor limit %d is too low for production sites. Recommend at least ulimit -n %d
\n
"
,
lim
,
min
)
}
}
}
}
// isLocalhost returns true if the string looks explicitly like a localhost address.
func
isLocalhost
(
s
string
)
bool
{
return
s
==
"localhost"
||
s
==
"::1"
||
strings
.
HasPrefix
(
s
,
"127."
)
...
...
This diff is collapsed.
Click to expand it.
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