Skip to content

Commit

Permalink
daemon: allow setting listen addr
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jul 8, 2019
1 parent cdca2ff commit d182c2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion daemon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import (
var Cmd = &cli.Command{
Name: "daemon",
Usage: "Start a lotus daemon process",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "api",
Value: ":1234",
},
},
Action: func(cctx *cli.Context) error {
ctx := context.Background()

Expand All @@ -26,6 +32,8 @@ var Cmd = &cli.Command{
return err
}

return serveRPC(api)


return serveRPC(api, cctx.String("api"))
},
}
4 changes: 2 additions & 2 deletions daemon/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
)

func serveRPC(api api.API) error {
func serveRPC(api api.API, addr string) error {
rpcServer := jsonrpc.NewServer()
rpcServer.Register("Filecoin", api)
http.Handle("/rpc/v0", rpcServer)
return http.ListenAndServe(":1234", http.DefaultServeMux)
return http.ListenAndServe(addr, http.DefaultServeMux)
}

0 comments on commit d182c2e

Please sign in to comment.