This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
66 lines (50 loc) · 1.47 KB
/
main.go
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
64
65
66
package main
import (
"flag"
"os"
"strings"
"github.com/cloudfoundry-incubator/cf-lager"
Bbs "github.com/cloudfoundry-incubator/runtime-schema/bbs"
"github.com/cloudfoundry/gunk/timeprovider"
"github.com/cloudfoundry/storeadapter/etcdstoreadapter"
"github.com/cloudfoundry/storeadapter/workerpool"
"github.com/pivotal-golang/lager"
"github.com/tedsuo/ifrit"
"github.com/tedsuo/ifrit/grouper"
"github.com/tedsuo/ifrit/sigmon"
"github.com/cloudfoundry-incubator/app-manager/handler"
"github.com/cloudfoundry-incubator/app-manager/lrpreprocessor"
)
var etcdCluster = flag.String(
"etcdCluster",
"http://127.0.0.1:4001",
"comma-separated list of etcd addresses (http://ip:port)",
)
func main() {
flag.Parse()
logger := cf_lager.New("app-manager")
bbs := initializeBbs(logger)
lrpp := lrpreprocessor.New(bbs)
group := grouper.EnvokeGroup(grouper.RunGroup{
"handler": handler.NewHandler(bbs, lrpp, logger),
})
logger.Info("started")
monitor := ifrit.Envoke(sigmon.New(group))
err := <-monitor.Wait()
if err != nil {
logger.Error("exited-with-failure", err)
os.Exit(1)
}
logger.Info("exited")
}
func initializeBbs(logger lager.Logger) Bbs.AppManagerBBS {
etcdAdapter := etcdstoreadapter.NewETCDStoreAdapter(
strings.Split(*etcdCluster, ","),
workerpool.NewWorkerPool(10),
)
err := etcdAdapter.Connect()
if err != nil {
logger.Fatal("failed-to-connect-to-etcd", err)
}
return Bbs.NewAppManagerBBS(etcdAdapter, timeprovider.NewTimeProvider(), logger)
}