@cryptotaxi247 / kubo / commits / b4fc0dba9

cmd/ipfs: Added basic daemon command

Matt Bell committed Oct 24, 2014 at 15:13 UTC b4fc0dba9620c86ac4523843d55e1c2180a6b583
2 files changed +28 -6
cmd/ipfs/daemon.go new
+27
@@ -0,0 +1,27 @@
1 +package main
2 +
3 +import (
4 + "net/http"
5 +
6 + cmds "github.com/jbenet/go-ipfs/commands"
7 + cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
8 +)
9 +
10 +var Daemon = &cmds.Command{
11 + Options: []cmds.Option{},
12 + Help: "TODO",
13 + Subcommands: map[string]*cmds.Command{},
14 + Run: daemonFunc,
15 +}
16 +
17 +func daemonFunc(req cmds.Request, res cmds.Response) {
18 + handler := cmdsHttp.Handler{}
19 + http.Handle(cmdsHttp.ApiPath+"/", handler)
20 + // TODO: load listen address/port from config/options
21 + err := http.ListenAndServe(":8080", nil)
22 + if err != nil {
23 + res.SetError(err, cmds.ErrNormal)
24 + return
25 + }
26 + // TODO: log to indicate that we are now listening
27 +}
cmd/ipfs/root.go
+1 -6
@@ -9,11 +9,6 @@ var Root = &cmds.Command{
9 Options: commands.Root.Options,
10 Help: commands.Root.Help,
11 Subcommands: map[string]*cmds.Command{
12 - "test": &cmds.Command{
13 - Run: func(req cmds.Request, res cmds.Response) {
14 - v := "hello, world"
15 - res.SetValue(v)
16 - },
17 - },
12 + "daemon": Daemon,
13 },
14 }