本文整理汇总了Golang中github.com/djbarber/ipfs-hack/core.IpfsNode.Process方法的典型用法代码示例。如果您正苦于以下问题:Golang IpfsNode.Process方法的具体用法?Golang IpfsNode.Process怎么用?Golang IpfsNode.Process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/djbarber/ipfs-hack/core.IpfsNode
的用法示例。
在下文中一共展示了IpfsNode.Process方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Mount
// Mount mounts ipfs at a given location, and returns a mount.Mount instance.
func Mount(ipfs *core.IpfsNode, mountpoint string) (mount.Mount, error) {
cfg, err := ipfs.Repo.Config()
if err != nil {
return nil, err
}
allow_other := cfg.Mounts.FuseAllowOther
fsys := NewFileSystem(ipfs)
return mount.NewMount(ipfs.Process(), fsys, mountpoint, allow_other)
}
示例2: Serve
func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error {
handler, err := makeHandler(node, lis, options...)
if err != nil {
return err
}
addr, err := manet.FromNetAddr(lis.Addr())
if err != nil {
return err
}
// if the server exits beforehand
var serverError error
serverExited := make(chan struct{})
node.Process().Go(func(p goprocess.Process) {
serverError = http.Serve(lis, handler)
close(serverExited)
})
// wait for server to exit.
select {
case <-serverExited:
// if node being closed before server exits, close server
case <-node.Process().Closing():
log.Infof("server at %s terminating...", addr)
lis.Close()
outer:
for {
// wait until server exits
select {
case <-serverExited:
// if the server exited as we are closing, we really dont care about errors
serverError = nil
break outer
case <-time.After(5 * time.Second):
log.Infof("waiting for server at %s to terminate...", addr)
}
}
}
log.Infof("server at %s terminated", addr)
return serverError
}