daemon: don't give C-c feedback until we actually start the daemon.
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Jan 7, 2019 at 19:23 UTC
0a1a223fd5caf8c564c77e1aaf51e45cbe677cb9
1 file changed
+8
-6
cmd/ipfs/daemon.go
+8
-6
@@ -211,12 +211,6 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
211
212
cctx := env.(*oldcmds.Context)
213
214
- go func() {
215
- <-req.Context.Done()
216
- fmt.Println("Received interrupt signal, shutting down...")
217
- fmt.Println("(Hit ctrl-c again to force-shutdown the daemon.)")
218
- }()
219
-
214
// check transport encryption flag.
215
unencrypted, _ := req.Options[unencryptTransportKwd].(bool)
216
if unencrypted {
@@ -393,6 +387,14 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
387
prometheus.MustRegister(&corehttp.IpfsNodeCollector{Node: node})
388
389
fmt.Printf("Daemon is ready\n")
390
+
391
+ // Give the user some immediate feedback when they hit C-c
392
+ go func() {
393
+ <-req.Context.Done()
394
+ fmt.Println("Received interrupt signal, shutting down...")
395
+ fmt.Println("(Hit ctrl-c again to force-shutdown the daemon.)")
396
+ }()
397
+
398
// collect long-running errors and block for shutdown
399
// TODO(cryptix): our fuse currently doesnt follow this pattern for graceful shutdown
400
for err := range merge(apiErrc, gwErrc, gcErrc) {