github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/cmd/ipfs/run.go (about) 1 package main 2 3 import ( 4 "os" 5 "os/signal" 6 "syscall" 7 8 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag" 9 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander" 10 ) 11 12 var cmdIpfsRun = &commander.Command{ 13 UsageLine: "run", 14 Short: "run local ifps node.", 15 Long: `run a local ipfs node with no other interface. 16 `, 17 Run: runCmd, 18 Flag: *flag.NewFlagSet("ipfs-run", flag.ExitOnError), 19 } 20 21 func runCmd(c *commander.Command, inp []string) error { 22 cc, err := setupCmdContext(c, true) 23 if err != nil { 24 return err 25 } 26 27 sigc := make(chan os.Signal, 1) 28 signal.Notify(sigc, syscall.SIGHUP, syscall.SIGINT, 29 syscall.SIGTERM, syscall.SIGQUIT) 30 31 // wait until we get a signal to exit. 32 <-sigc 33 34 cc.daemon.Close() 35 return nil 36 }