hide fd adjusting code behind daemon feature flag
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Apr 6, 2016 at 18:13 UTC
e661832575a26610bfee55f370961b2ce11b489b
3 files changed
+8
-6
cmd/ipfs/daemon.go
+7
-2
@@ -40,6 +40,7 @@ const (
40
unrestrictedApiAccessKwd = "unrestricted-api"
41
unencryptTransportKwd = "disable-transport-encryption"
42
enableGCKwd = "enable-gc"
43
+ adjustFDLimitKwd = "manage-fdlimit"
44
// apiAddrKwd = "address-api"
45
// swarmAddrKwd = "address-swarm"
46
)
@@ -132,6 +133,7 @@ future version, along with this notice. Please move to setting the HTTP Headers.
133
cmds.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"),
134
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
135
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"),
136
+ cmds.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed"),
137
138
// TODO: add way to override addresses. tricky part: updating the config if also --init.
139
// cmds.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
@@ -158,8 +160,11 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
160
// let the user know we're going.
161
fmt.Printf("Initializing daemon...\n")
162
161
- if err := fileDescriptorCheck(); err != nil {
162
- log.Error("setting file descriptor limit: %s", err)
163
+ managefd, _, _ := req.Option(adjustFDLimitKwd).Bool()
164
+ if managefd {
165
+ if err := fileDescriptorCheck(); err != nil {
166
+ log.Error("setting file descriptor limit: %s", err)
167
+ }
168
}
169
170
ctx := req.InvocContext()
cmd/ipfs/ulimit_unix.go
+1
-1
@@ -9,7 +9,7 @@ import (
9
"syscall"
10
)
11
12
-var ipfsFileDescNum = uint64(1024)
12
+var ipfsFileDescNum = uint64(2048)
13
14
func init() {
15
if val := os.Getenv("IPFS_FD_MAX"); val != "" {
test/sharness/t0061-daemon-opts.sh
-3
@@ -13,9 +13,6 @@ test_init_ipfs
13
14
test_launch_ipfs_daemon --unrestricted-api --disable-transport-encryption
15
16
-test_expect_success "convert addresses from multiaddrs" '
17
-'
18
-
16
gwyaddr=$GWAY_ADDR
17
apiaddr=$API_ADDR
18