Skip to content

Commit

Permalink
use cli and configor
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Oct 2, 2019
1 parent ea54ec5 commit bfa656f
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
core
dev.yaml
dev*.yaml
eru-core
core.yaml
core.yml
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM golang:alpine AS BUILD

# make binary
RUN apk add --no-cache build-base musl-dev libgit2-dev git curl make cmake python\
&& go get -d github.com/projecteru2/core
RUN apk add --no-cache build-base musl-dev libgit2-dev git curl make cmake python
RUN git clone https://github.com/projecteru2/core.git /go/src/github.com/projecteru2/core
WORKDIR /go/src/github.com/projecteru2/core
RUN make build && ./eru-core --version

Expand Down
19 changes: 0 additions & 19 deletions Dockerfile.debian

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.09.30
19.10.01
2 changes: 1 addition & 1 deletion cluster/calcium/calcium.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func New(config types.Config, embededStorage bool) (*Calcium, error) {
case cluster.Github:
scm = github.New(config)
default:
log.Warn("[Calcium] SCM not set, build API disable")
log.Warn("[Calcium] SCM not set, build API disabled")
}

return &Calcium{store: store, config: config, scheduler: scheduler, source: scm}, nil
Expand Down
46 changes: 26 additions & 20 deletions core.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"net"
"net/http"
_ "net/http/pprof"
Expand All @@ -17,7 +18,7 @@ import (
"github.com/projecteru2/core/versioninfo"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
cli "github.com/urfave/cli/v2"
"google.golang.org/grpc"
)

Expand All @@ -42,20 +43,12 @@ func setupLog(l string) error {
}

func serve() {
if configPath == "" {
log.Fatal("[main] Config path must be set")
}

config, err := utils.LoadConfig(configPath)
if err != nil {
log.Fatalf("[main] %v", err)
}

logLevel := "INFO"
if config.LogLevel != "" {
logLevel = config.LogLevel
}
if err := setupLog(logLevel); err != nil {
if err := setupLog(config.LogLevel); err != nil {
log.Fatalf("[main] %v", err)
}

Expand Down Expand Up @@ -114,19 +107,32 @@ func serve() {
}

func main() {
cli := &cobra.Command{
Use: versioninfo.NAME,
Short: versioninfo.NAME,
Long: versioninfo.NAME,
Version: versioninfo.VersionString(),
cli.VersionPrinter = func(c *cli.Context) {
fmt.Print(versioninfo.VersionString())
}

cli.Flags().StringVarP(&configPath, "config", "c", "/etc/eru/core.yaml", "config file path for core")
cli.Flags().BoolVarP(&embeddedStorage, "embeded-storage", "e", false, "active embedded storage")

cli.Run = func(cmd *cobra.Command, args []string) {
app := cli.NewApp()
app.Name = versioninfo.NAME
app.Usage = "Run eru core"
app.Version = versioninfo.VERSION
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "config",
Value: "/etc/eru/core.yaml",
Usage: "config file path for core, in yaml",
Destination: &configPath,
EnvVars: []string{"ERU_CONFIG_PATH"},
},
&cli.BoolFlag{
Name: "embedded-storage",
Usage: "active embedded storage",
Destination: &embeddedStorage,
},
}
app.Action = func(c *cli.Context) error {
serve()
return nil
}

cli.Execute()
app.Run(os.Args)
}
14 changes: 3 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,51 @@ require (
github.com/containerd/continuity v0.0.0-20180612233548-246e49050efd // indirect
github.com/coreos/bbolt v1.3.1-coreos.6 // indirect
github.com/coreos/etcd v3.3.13+incompatible
github.com/coreos/go-semver v0.2.0 // indirect
github.com/coreos/go-systemd v0.0.0-20170731111925-d21964639418 // indirect
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf // indirect
github.com/creack/pty v1.1.9 // indirect
github.com/dgrijalva/jwt-go v3.0.0+incompatible // indirect
github.com/docker/distribution v0.0.0-20171207180435-f4118485915a
github.com/docker/docker v0.0.0-20181112142024-a5e2dd2bb141
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.3.3
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-check/check v0.0.0-20180628173108-788fd7840127 // indirect
github.com/golang/protobuf v1.3.2
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/mux v0.0.0-20180605211556-cb4698366aa6 // indirect
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c // indirect
github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20181112102510-3304cc886352 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170826090648-0dafe0d496ea // indirect
github.com/grpc-ecosystem/grpc-gateway v1.3.0 // indirect
github.com/jinzhu/configor v1.1.1
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/json-iterator/go v1.1.6 // indirect
github.com/libgit2/git2go v0.0.0-20190813182810-37e5b53f742d
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v0.0.0-20180411145040-e562b0440392 // indirect
github.com/opencontainers/runc v0.0.0-20180615140650-ad0f5255060d // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/philhofer/fwd v1.0.0 // indirect
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7 // indirect
github.com/projecteru2/libyavirt v0.0.0-20190927033610-01b2baa9a637
github.com/prometheus/client_golang v0.9.3
github.com/sanity-io/litter v1.1.0
github.com/sirupsen/logrus v1.4.2
github.com/soheilhy/cmux v0.1.3 // indirect
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.3.0
github.com/tinylib/msgp v1.1.0 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8 // indirect
github.com/urfave/cli/v2 v2.0.0-alpha.2
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 // indirect
go.uber.org/atomic v1.3.2 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.7.1 // indirect
golang.org/x/crypto v0.0.0-20190926180335-cea2066c6411 // indirect
golang.org/x/exp v0.0.0-20190925190815-26a69ce95baf // indirect
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17
golang.org/x/sys v0.0.0-20190926180325-855e68c8590b // indirect
golang.org/x/tools v0.0.0-20190926165942-a8d5d34286bd // indirect
google.golang.org/appengine v1.6.4 // indirect
google.golang.org/genproto v0.0.0-20190926190326-7ee9db18f195 // indirect
google.golang.org/grpc v1.24.0
gopkg.in/alexcesaro/statsd.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.2.2
gotest.tools v2.2.0+incompatible // indirect
)

Expand Down
Loading

0 comments on commit bfa656f

Please sign in to comment.