From 3e4078818884174e362565e8bdd9cb7d04dc27ef Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 21 Oct 2014 13:02:25 +0200 Subject: [PATCH] updateApply: force shutdown check on daemon (TODO: force flag in cli) --- core/commands/update.go | 23 +++++++++++++++++++++-- daemon/daemon.go | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/core/commands/update.go b/core/commands/update.go index 95a4f8a44..67a1f6285 100644 --- a/core/commands/update.go +++ b/core/commands/update.go @@ -24,13 +24,32 @@ func UpdateApply(n *core.IpfsNode, args []string, opts map[string]interface{}, o } fmt.Fprintln(out, "New Version:", u.Version) + _, onDaemon := opts["onDaemon"] + _, force := opts["force"] + if onDaemon && !force { + return fmt.Errorf(`Error: update must stop running ipfs service. +You may want to abort the update, or shut the service down manually. +To shut it down automatically, run: + + ipfs update apply -f +`) + } + if err = updates.Apply(u); err != nil { fmt.Fprint(out, err.Error()) return fmt.Errorf("Couldn't apply update: %v", err) } - fmt.Fprintln(out, "Updated applied! Shutting down.") - os.Exit(0) + fmt.Fprintln(out, "Updated applied!") + if onDaemon { + if force { + fmt.Fprintln(out, "Shutting down ipfs service.") + os.Exit(1) // is there a cleaner shutdown routine? + } else { + fmt.Fprintln(out, "You can now restart the ipfs service.") + } + } + return nil } diff --git a/daemon/daemon.go b/daemon/daemon.go index b4241e16b..a3790971e 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -142,6 +142,7 @@ func (dl *DaemonListener) handleConnection(conn manet.Conn) { case "unpin": err = commands.Unpin(dl.node, command.Args, command.Opts, conn) case "updateApply": + command.Opts["onDaemon"] = true err = commands.UpdateApply(dl.node, command.Args, command.Opts, conn) default: err = fmt.Errorf("Invalid Command: '%s'", command.Command)