Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce verbosity of daemon start #5904

Merged
merged 3 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func defaultMux(path string) corehttp.ServeOption {
}
}

func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) (_err error) {
// Inject metrics before we do anything
err := mprome.Inject()
if err != nil {
Expand All @@ -195,28 +195,27 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
// let the user know we're going.
fmt.Printf("Initializing daemon...\n")

defer func() {
if _err != nil {
// Print an extra line before any errors. This could go
// in the commands lib but doesn't really make sense for
// all commands.
fmt.Println()
}
}()

// print the ipfs version
printVersion()

managefd, _ := req.Options[adjustFDLimitKwd].(bool)
if managefd {
if changedFds, newFdsLimit, err := utilmain.ManageFdLimit(); err != nil {
if _, _, err := utilmain.ManageFdLimit(); err != nil {
log.Errorf("setting file descriptor limit: %s", err)
} else {
if changedFds {
fmt.Printf("Successfully raised file descriptor limit to %d.\n", newFdsLimit)
}
}
}

cctx := env.(*oldcmds.Context)

go func() {
<-req.Context.Done()
fmt.Println("Received interrupt signal, shutting down...")
fmt.Println("(Hit ctrl-c again to force-shutdown the daemon.)")
}()

// check transport encryption flag.
unencrypted, _ := req.Options[unencryptTransportKwd].(bool)
if unencrypted {
Expand Down Expand Up @@ -393,6 +392,14 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
prometheus.MustRegister(&corehttp.IpfsNodeCollector{Node: node})

fmt.Printf("Daemon is ready\n")

// Give the user some immediate feedback when they hit C-c
go func() {
<-req.Context.Done()
fmt.Println("Received interrupt signal, shutting down...")
fmt.Println("(Hit ctrl-c again to force-shutdown the daemon.)")
}()

// collect long-running errors and block for shutdown
// TODO(cryptix): our fuse currently doesnt follow this pattern for graceful shutdown
for err := range merge(apiErrc, gwErrc, gcErrc) {
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/t0060-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ TEST_ULIMIT_PRESET=1
test_launch_ipfs_daemon

test_expect_success "daemon raised its fd limit" '
grep "raised file descriptor limit to 2048." actual_daemon > /dev/null
grep -v "setting file descriptor limit" actual_daemon > /dev/null
'

test_expect_success "daemon actually can handle 2048 file descriptors" '
Expand Down