[REV] merge branch

This commit is contained in:
barnettZQG 2018-06-14 10:49:31 +08:00
commit d9f59ae562
6 changed files with 57 additions and 39 deletions

View File

@ -75,17 +75,17 @@ Rainbond is under the LGPL-3.0 license, see [LICENSE](https://github.com/goodrai
Thanks for the following open source project Thanks for the following open source project
* [kubernetes](https://github.com/kubernetes/kubernetes) * [Kubernetes](https://github.com/kubernetes/kubernetes)
* [docker/moby](https://github.com/moby/moby) * [Docker/Moby](https://github.com/moby/moby)
* [heroku buildpack](https://github.com/heroku) * [Heroku Buildpacks](https://github.com/heroku?utf8=%E2%9C%93&q=buildpack&type=&language=)
* [openresty](https://github.com/openresty/) * [OpenResty](https://github.com/openresty/)
* [calico](https://github.com/projectcalico) * [Calico](https://github.com/projectcalico)
* [midonet](https://github.com/midonet/midonet) * [Midonet](https://github.com/midonet/midonet)
* [etcd](https://github.com/coreos/etcd) * [Etcd](https://github.com/coreos/etcd)
* [prometheus](https://github.com/prometheus/prometheus) * [Prometheus](https://github.com/prometheus/prometheus)
* [glusterfs](https://github.com/gluster/glusterfs) * [GlusterFS](https://github.com/gluster/glusterfs)
* [ceph](https://github.com/ceph/ceph) * [Ceph](https://github.com/ceph/ceph)
* [cockroachDB](https://github.com/cockroachdb/cockroach) * [CockroachDB](https://github.com/cockroachdb/cockroach)
* [mysql](https://github.com/mysqljs/mysql) * [MySQL](https://github.com/mysql/mysql-server)
* [Weave Scope](https://github.com/weaveworks/scope) * [Weave Scope](https://github.com/weaveworks/scope)
* [Ant Design](https://github.com/ant-design/ant-design) * [Ant Design](https://github.com/ant-design/ant-design)

View File

@ -16,8 +16,11 @@ import (
"github.com/goodrain/rainbond/mq/api/grpc/pb" "github.com/goodrain/rainbond/mq/api/grpc/pb"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"regexp"
) )
var re = regexp.MustCompile(`\s`)
type AppAction struct { type AppAction struct {
MQClient pb.TaskQueueClient MQClient pb.TaskQueueClient
staticDir string staticDir string
@ -160,7 +163,7 @@ func unicode2zh(uText string) (context string) {
} }
context = strings.TrimSpace(context) context = re.ReplaceAllString(context, "")
return context return context
} }

View File

@ -37,8 +37,11 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"regexp"
) )
var re = regexp.MustCompile(`\s`)
//ExportApp Export app to specified format(rainbond-app or dockercompose) //ExportApp Export app to specified format(rainbond-app or dockercompose)
type ExportApp struct { type ExportApp struct {
EventID string `json:"event_id"` EventID string `json:"event_id"`
@ -654,7 +657,7 @@ func buildToLinuxFileName(fileName string) string {
} }
fileName = strings.Replace(fileName, ":", "--", -1) fileName = strings.Replace(fileName, ":", "--", -1)
fileName = strings.TrimSpace(fileName) fileName = re.ReplaceAllString(fileName, "")
return fileName return fileName
} }

View File

@ -29,6 +29,7 @@ import (
) )
type Config struct { type Config struct {
EtcdEndpointsLine string
EtcdEndpoints []string EtcdEndpoints []string
LogLevel string LogLevel string
AdvertiseAddr string AdvertiseAddr string
@ -87,7 +88,8 @@ func NewConfig() *Config {
host, _ := os.Hostname() host, _ := os.Hostname()
config := &Config{ config := &Config{
EtcdEndpoints: []string{"http://127.0.0.1:2379"}, EtcdEndpointsLine: "http://127.0.0.1:2379",
EtcdEndpoints: []string{},
AdvertiseAddr: host + ":9999", AdvertiseAddr: host + ":9999",
BindIp: host, BindIp: host,
Port: 9999, Port: 9999,
@ -119,7 +121,7 @@ func NewConfig() *Config {
} }
func (c *Config) AddFlag(cmd *pflag.FlagSet) { func (c *Config) AddFlag(cmd *pflag.FlagSet) {
cmd.StringArrayVar(&c.EtcdEndpoints, "etcd-endpoints", c.EtcdEndpoints, "etcd endpoints list.") cmd.StringVar(&c.EtcdEndpointsLine, "etcd-endpoints", c.EtcdEndpointsLine, "etcd endpoints list.")
cmd.StringVar(&c.AdvertiseAddr, "advertise-addr", c.AdvertiseAddr, "advertise address, and registry into etcd.") cmd.StringVar(&c.AdvertiseAddr, "advertise-addr", c.AdvertiseAddr, "advertise address, and registry into etcd.")
} }
@ -173,6 +175,16 @@ func (c *Config) AddPrometheusFlag(cmd *pflag.FlagSet) {
} }
func (c *Config) CompleteConfig() { func (c *Config) CompleteConfig() {
// parse etcd urls line to array
for _, url := range strings.Split(c.EtcdEndpointsLine, ",") {
c.EtcdEndpoints = append(c.EtcdEndpoints, url)
}
if len(c.EtcdEndpoints) < 1 {
logrus.Error("Must define the etcd endpoints by --etcd-endpoints")
os.Exit(17)
}
// parse values from prometheus options to config // parse values from prometheus options to config
ipPort := strings.TrimLeft(c.AdvertiseAddr, "shttp://") ipPort := strings.TrimLeft(c.AdvertiseAddr, "shttp://")
ipPortArr := strings.Split(ipPort, ":") ipPortArr := strings.Split(ipPort, ":")

View File

@ -70,8 +70,8 @@ func (e *App) toScrape() *prometheus.ScrapeConfig {
return &prometheus.ScrapeConfig{ return &prometheus.ScrapeConfig{
JobName: e.Name(), JobName: e.Name(),
ScrapeInterval: model.Duration(1 * time.Minute), ScrapeInterval: model.Duration(5 * time.Second),
ScrapeTimeout: model.Duration(30 * time.Second), ScrapeTimeout: model.Duration(4 * time.Second),
MetricsPath: "/app/metrics", MetricsPath: "/app/metrics",
ServiceDiscoveryConfig: prometheus.ServiceDiscoveryConfig{ ServiceDiscoveryConfig: prometheus.ServiceDiscoveryConfig{
StaticConfigs: []*prometheus.Group{ StaticConfigs: []*prometheus.Group{

View File

@ -73,17 +73,17 @@ Rainbond遵循LGPL-3.0 license协议发布详情查看[LICENSE](https://githu
感谢以下开源项目 感谢以下开源项目
* [kubernetes](https://github.com/kubernetes/kubernetes) * [Kubernetes](https://github.com/kubernetes/kubernetes)
* [docker/moby](https://github.com/moby/moby) * [Docker/Moby](https://github.com/moby/moby)
* [heroku buildpack](https://github.com/heroku) * [Heroku Buildpacks](https://github.com/heroku?utf8=%E2%9C%93&q=buildpack&type=&language=)
* [openresty](https://github.com/openresty/) * [OpenResty](https://github.com/openresty/)
* [calico](https://github.com/projectcalico) * [Calico](https://github.com/projectcalico)
* [midonet](https://github.com/midonet/midonet) * [Midonet](https://github.com/midonet/midonet)
* [etcd](https://github.com/coreos/etcd) * [Etcd](https://github.com/coreos/etcd)
* [prometheus](https://github.com/prometheus/prometheus) * [Prometheus](https://github.com/prometheus/prometheus)
* [glusterfs](https://github.com/gluster/glusterfs) * [GlusterFS](https://github.com/gluster/glusterfs)
* [ceph](https://github.com/ceph/ceph) * [Ceph](https://github.com/ceph/ceph)
* [cockroachDB](https://github.com/cockroachdb/cockroach) * [CockroachDB](https://github.com/cockroachdb/cockroach)
* [mysql](https://github.com/mysqljs/mysql) * [MySQL](https://github.com/mysql/mysql-server)
* [Weave Scope](https://github.com/weaveworks/scope) * [Weave Scope](https://github.com/weaveworks/scope)
* [Ant Design](https://github.com/ant-design/ant-design) * [Ant Design](https://github.com/ant-design/ant-design)