1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-28 00:39:31 +08:00

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

This commit is contained in:
Henry
2014-10-21 13:02:25 +02:00
parent 0a0c38fb91
commit 3e40788188
2 changed files with 22 additions and 2 deletions

View File

@ -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
}

View File

@ -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)