1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 09:59:13 +08:00

daemon listener to http serve code

This commit is contained in:
verokarhu
2014-09-16 20:05:48 +03:00
parent 8eb95faf50
commit d894d6382f

View File

@ -3,8 +3,10 @@ package main
import (
"errors"
"fmt"
"github.com/gonuts/flag"
"github.com/jbenet/commander"
"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"
h "github.com/jbenet/go-ipfs/server/http"
)
@ -36,13 +38,20 @@ func serveHttpCmd(c *commander.Command, _ []string) error {
return errors.New("invalid port number")
}
hostname := c.Flag.Lookup("hostname").Value.Get().(string)
n, err := localNode()
n, err := localNode(true)
if err != nil {
return err
}
fmt.Println("starting new daemon listener...")
dl, err := daemon.NewDaemonListener(n, "localhost:12345")
if err != nil {
return err
}
go dl.Listen()
defer dl.Close()
hostname := c.Flag.Lookup("hostname").Value.Get().(string)
address := fmt.Sprintf("%s:%d", hostname, port)
fmt.Printf("Serving on %s\n", address)