mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 01:12:24 +08:00
updateApply: force shutdown check on daemon (TODO: force flag in cli)
This commit is contained in:
@ -24,13 +24,32 @@ func UpdateApply(n *core.IpfsNode, args []string, opts map[string]interface{}, o
|
|||||||
}
|
}
|
||||||
fmt.Fprintln(out, "New Version:", u.Version)
|
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 {
|
if err = updates.Apply(u); err != nil {
|
||||||
fmt.Fprint(out, err.Error())
|
fmt.Fprint(out, err.Error())
|
||||||
return fmt.Errorf("Couldn't apply update: %v", err)
|
return fmt.Errorf("Couldn't apply update: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintln(out, "Updated applied! Shutting down.")
|
fmt.Fprintln(out, "Updated applied!")
|
||||||
os.Exit(0)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +142,7 @@ func (dl *DaemonListener) handleConnection(conn manet.Conn) {
|
|||||||
case "unpin":
|
case "unpin":
|
||||||
err = commands.Unpin(dl.node, command.Args, command.Opts, conn)
|
err = commands.Unpin(dl.node, command.Args, command.Opts, conn)
|
||||||
case "updateApply":
|
case "updateApply":
|
||||||
|
command.Opts["onDaemon"] = true
|
||||||
err = commands.UpdateApply(dl.node, command.Args, command.Opts, conn)
|
err = commands.UpdateApply(dl.node, command.Args, command.Opts, conn)
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("Invalid Command: '%s'", command.Command)
|
err = fmt.Errorf("Invalid Command: '%s'", command.Command)
|
||||||
|
Reference in New Issue
Block a user