As a self-taught go developer I constantly refer to go-ipfs code to understand some of the good coding patterns.
I am working on something where I programatically start the ipfs node. I was trying to understand the shutdown code.
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
nd, err := cmdenv.GetNode(env)
if err != nil {
return err
}
if !nd.IsDaemon {
return cmds.Errorf(cmds.ErrClient, "daemon not running")
}
if err := nd.Close(); err != nil {
log.Error("error while shutting down ipfs daemon:", err)
}
return nil
},
The ipfs daemon is running in a separate process. How is this command able to stop the same running node? Is there some way this cmdenv is able to share memory between processes?
I might have to go much deeper in code to understand this, so if anyone knows it on the top of their head I would really appreciate it!