mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
add run command
This commit is contained in:
parent
b5fd9492d7
commit
da1890e5ef
@ -51,6 +51,7 @@ Use "ipfs help <command>" for more information about a command.
|
||||
cmdIpfsMount,
|
||||
cmdIpfsInit,
|
||||
cmdIpfsServe,
|
||||
cmdIpfsRun,
|
||||
},
|
||||
Flag: *flag.NewFlagSet("ipfs", flag.ExitOnError),
|
||||
}
|
||||
|
||||
34
cmd/ipfs/run.go
Normal file
34
cmd/ipfs/run.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
|
||||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
|
||||
"github.com/jbenet/go-ipfs/daemon"
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
)
|
||||
|
||||
var cmdIpfsRun = &commander.Command{
|
||||
UsageLine: "run",
|
||||
Short: "run local ifps node.",
|
||||
Long: `run a local ipfs node with no other interface.
|
||||
`,
|
||||
Run: runCmd,
|
||||
Flag: *flag.NewFlagSet("ipfs-run", flag.ExitOnError),
|
||||
}
|
||||
|
||||
func runCmd(c *commander.Command, inp []string) error {
|
||||
u.Debug = true
|
||||
|
||||
n, err := localNode(true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dl, err := daemon.NewDaemonListener(n, "localhost:12345")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dl.Listen()
|
||||
dl.Close()
|
||||
return nil
|
||||
}
|
||||
@ -98,7 +98,11 @@ func (s *Node) Attr() fuse.Attr {
|
||||
case mdag.PBData_File, mdag.PBData_Raw:
|
||||
u.DOut("this is a file.\n")
|
||||
size, _ := s.Nd.Size()
|
||||
return fuse.Attr{Mode: 0444, Size: uint64(size)}
|
||||
return fuse.Attr{
|
||||
Mode: 0444,
|
||||
Size: uint64(size),
|
||||
Blocks: uint64(len(s.Nd.Links)),
|
||||
}
|
||||
default:
|
||||
u.PErr("Invalid data type.")
|
||||
return fuse.Attr{}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user