-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathboot.go
More file actions
63 lines (56 loc) · 1.46 KB
/
boot.go
File metadata and controls
63 lines (56 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"os"
"runtime"
"github.com/codegangsta/cli"
"github.com/deis/builder/fetcher"
"github.com/deis/builder/pkg"
"github.com/deis/builder/pkg/conf"
"github.com/deis/builder/pkg/gitreceive"
"github.com/deis/builder/pkg/log"
"github.com/deis/builder/pkg/sshd"
)
const (
serverConfAppName = "deis-builder-server"
gitReceiveConfAppName = "deis-builder-git-receive"
)
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
}
func main() {
app := cli.NewApp()
app.Commands = []cli.Command{
{
Name: "server",
Aliases: []string{"srv"},
Usage: "Run the git server",
Action: func(c *cli.Context) {
cnf := new(sshd.Config)
if err := conf.EnvConfig(serverConfAppName, cnf); err != nil {
log.Err("getting config for %s [%s]", serverConfAppName, err)
os.Exit(1)
}
log.Info("starting fetcher on port %d", cnf.FetcherPort)
go fetcher.Serve(cnf.FetcherPort)
os.Exit(pkg.Run(cnf.SSHHostIP, cnf.SSHHostPort, "boot"))
},
},
{
Name: "git-receive",
Aliases: []string{"gr"},
Usage: "Run the git-receive hook",
Action: func(c *cli.Context) {
cnf := new(gitreceive.Config)
if err := conf.EnvConfig(gitReceiveConfAppName, cnf); err != nil {
log.Err("Error getting config for %s [%s]", gitReceiveConfAppName, err)
os.Exit(1)
}
if err := gitreceive.Run(cnf); err != nil {
log.Err("running git receive hook [%s]", err)
os.Exit(1)
}
},
},
}
app.Run(os.Args)
}