From 0a1a223fd5caf8c564c77e1aaf51e45cbe677cb9 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 7 Jan 2019 19:23:41 -0800 Subject: [PATCH 1/3] daemon: don't give C-c feedback until we actually start the daemon. License: MIT Signed-off-by: Steven Allen --- cmd/ipfs/daemon.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 88da7ff962d..08b96d875e7 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -211,12 +211,6 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment 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 { @@ -393,6 +387,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) { From 7a9b1716f9a6f84e7611f08a97e9b546bd1ebf92 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 7 Jan 2019 19:25:10 -0800 Subject: [PATCH 2/3] daemon: don't print anything when raising file descriptor limit This isn't an error and 99.999% of users won't care. License: MIT Signed-off-by: Steven Allen --- cmd/ipfs/daemon.go | 6 +----- test/sharness/t0060-daemon.sh | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 08b96d875e7..efe706765d8 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -200,12 +200,8 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment 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) - } } } diff --git a/test/sharness/t0060-daemon.sh b/test/sharness/t0060-daemon.sh index 3c57981570c..a33acb1eb7e 100755 --- a/test/sharness/t0060-daemon.sh +++ b/test/sharness/t0060-daemon.sh @@ -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" ' From 5f048311900b365fe2e417d93651bf137eab19a2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 8 Jan 2019 13:20:12 -0800 Subject: [PATCH 3/3] daemon: print a newline before errors The `ipfs init` command prints out a ton of information which can make it hard to spot errors. Print a newline before these errors We could do this for every command but there are some tricky edge cases: 1. This would look funny if there's no other output. 2. It might mess break tools parsing the output (not expecting empty lines). License: MIT Signed-off-by: Steven Allen --- cmd/ipfs/daemon.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index efe706765d8..b048bb9fb04 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -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 { @@ -195,6 +195,15 @@ 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()