@cryptotaxi247 / kubo / commits / 3e4078818

updateApply: force shutdown check on daemon (TODO: force flag in cli)

Henry committed Oct 21, 2014 at 13:02 UTC 3e4078818884174e362565e8bdd9cb7d04dc27ef
2 files changed +22 -2
core/commands/update.go
+21 -2
@@ -24,13 +24,32 @@ func UpdateApply(n *core.IpfsNode, args []string, opts map[string]interface{}, o
24 }
25 fmt.Fprintln(out, "New Version:", u.Version)
26
27 + _, onDaemon := opts["onDaemon"]
28 + _, force := opts["force"]
29 + if onDaemon && !force {
30 + return fmt.Errorf(`Error: update must stop running ipfs service.
31 +You may want to abort the update, or shut the service down manually.
32 +To shut it down automatically, run:
33 +
34 + ipfs update apply -f
35 +`)
36 + }
37 +
38 if err = updates.Apply(u); err != nil {
39 fmt.Fprint(out, err.Error())
40 return fmt.Errorf("Couldn't apply update: %v", err)
41 }
42
32 - fmt.Fprintln(out, "Updated applied! Shutting down.")
33 - os.Exit(0)
43 + fmt.Fprintln(out, "Updated applied!")
44 + if onDaemon {
45 + if force {
46 + fmt.Fprintln(out, "Shutting down ipfs service.")
47 + os.Exit(1) // is there a cleaner shutdown routine?
48 + } else {
49 + fmt.Fprintln(out, "You can now restart the ipfs service.")
50 + }
51 + }
52 +
53 return nil
54 }
55
daemon/daemon.go
+1
@@ -142,6 +142,7 @@ func (dl *DaemonListener) handleConnection(conn manet.Conn) {
142 case "unpin":
143 err = commands.Unpin(dl.node, command.Args, command.Opts, conn)
144 case "updateApply":
145 + command.Opts["onDaemon"] = true
146 err = commands.UpdateApply(dl.node, command.Args, command.Opts, conn)
147 default:
148 err = fmt.Errorf("Invalid Command: '%s'", command.Command)