Skip to content

Commit

Permalink
Merge pull request #5904 from ipfs/feat/quiet-init
Browse files Browse the repository at this point in the history
reduce verbosity of daemon start
  • Loading branch information
Stebalien authored Jan 9, 2019
2 parents 1b5c71f + 5f04831 commit c8c348b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
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

0 comments on commit c8c348b

Please sign in to comment.