mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-11 07:03:32 +08:00
Check to see if the daemon is currently running
If the daemon is running we do not want to proceed with an an initialization. Return a client error telling the user to kill the daemon before proceeding with the command.
This commit is contained in:
@ -35,6 +35,17 @@ var initCmd = &cmds.Command{
|
|||||||
// name of the file?
|
// name of the file?
|
||||||
// TODO cmds.StringOption("event-logs", "l", "Location for machine-readable event logs"),
|
// TODO cmds.StringOption("event-logs", "l", "Location for machine-readable event logs"),
|
||||||
},
|
},
|
||||||
|
PreRun: func(req cmds.Request) error {
|
||||||
|
daemonLocked := fsrepo.LockedByOtherProcess(req.Context().ConfigRoot)
|
||||||
|
|
||||||
|
log.Info("checking if daemon is running...")
|
||||||
|
if daemonLocked {
|
||||||
|
e := "ipfs daemon is running. please stop it to run this command"
|
||||||
|
return cmds.ClientError(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
Run: func(req cmds.Request, res cmds.Response) {
|
Run: func(req cmds.Request, res cmds.Response) {
|
||||||
|
|
||||||
force, _, err := req.Option("f").Bool() // if !found, it's okay force == false
|
force, _, err := req.Option("f").Bool() // if !found, it's okay force == false
|
||||||
|
Reference in New Issue
Block a user