[
https://issues.apache.org/jira/browse/SCB-797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16596360#comment-16596360
]
ASF GitHub Bot commented on SCB-797:
------------------------------------
little-cui closed pull request #434: SCB-797 More information in dump API
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/434
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/etc/conf/app.conf b/etc/conf/app.conf
index 16fe4842..f48935af 100644
--- a/etc/conf/app.conf
+++ b/etc/conf/app.conf
@@ -36,8 +36,10 @@ read_header_timeout = 60s
read_timeout = 60s
idle_timeout = 60s
write_timeout = 60s
-max_header_bytes = 32768 # 32K
-max_body_bytes = 2097152 # 2M
+# 32K
+max_header_bytes = 32768
+# 2M
+max_body_bytes = 2097152
enable_pprof = 0
@@ -65,9 +67,6 @@ manager_cluster = "127.0.0.1:2379"
# default 30s if value less then 0
auto_sync_interval = 30s
-# bootstrap time out of registry
-connect_timeout = 10s
-
# request registry time out
registry_timeout = 30s
diff --git a/server/admin/model/dump.go b/server/admin/model/dump.go
index 8c9ea878..3354d7c6 100644
--- a/server/admin/model/dump.go
+++ b/server/admin/model/dump.go
@@ -183,7 +183,7 @@ type DumpRequest struct {
type DumpResponse struct {
Response *pb.Response `json:"response,omitempty"`
Info *version.VersionSet `json:"info,omitempty"`
- Config *pb.ServerConfig `json:"config,omitempty"`
+ Config map[string]string `json:"config,omitempty"`
Environments map[string]string `json:"environments,omitempty"`
Cache *Cache `json:"cache,omitempty"`
}
diff --git a/server/admin/service.go b/server/admin/service.go
index 82322ef9..91689b21 100644
--- a/server/admin/service.go
+++ b/server/admin/service.go
@@ -25,6 +25,7 @@ import (
pb
"github.com/apache/incubator-servicecomb-service-center/server/core/proto"
scerr
"github.com/apache/incubator-servicecomb-service-center/server/error"
"github.com/apache/incubator-servicecomb-service-center/version"
+ "github.com/astaxie/beego"
"golang.org/x/net/context"
"os"
"strings"
@@ -32,6 +33,7 @@ import (
var (
AdminServiceAPI = &AdminService{}
+ configs map[string]string
environments = make(map[string]string)
)
@@ -40,6 +42,12 @@ func init() {
arr := strings.Split(kv, "=")
environments[arr[0]] = arr[1]
}
+ configs, _ = beego.AppConfig.GetSection("default")
+ if section, err := beego.AppConfig.GetSection(beego.BConfig.RunMode);
err == nil {
+ for k, v := range section {
+ configs[k] = v
+ }
+ }
}
type AdminService struct {
@@ -61,7 +69,7 @@ func (service *AdminService) Dump(ctx context.Context, in
*model.DumpRequest) (*
return &model.DumpResponse{
Response: pb.CreateResponse(pb.Response_SUCCESS, "Admin
dump successfully"),
Info: version.Ver(),
- Config: &core.ServerInfo.Config,
+ Config: configs,
Environments: environments,
Cache: &cache,
}, nil
diff --git a/server/core/config.go b/server/core/config.go
index 17151179..33876e7e 100644
--- a/server/core/config.go
+++ b/server/core/config.go
@@ -17,8 +17,13 @@
package core
import (
+ "github.com/apache/incubator-servicecomb-service-center/pkg/log"
+ "github.com/apache/incubator-servicecomb-service-center/pkg/plugin"
pb
"github.com/apache/incubator-servicecomb-service-center/server/core/proto"
+ "github.com/apache/incubator-servicecomb-service-center/version"
"github.com/astaxie/beego"
+ "os"
+ "runtime"
)
const (
@@ -28,7 +33,15 @@ const (
var ServerInfo = new(pb.ServerInformation)
func Configure() {
+ setCPUs()
+
*ServerInfo = newInfo()
+
+ plugin.SetPluginDir(ServerInfo.Config.PluginsDir)
+
+ initLogger()
+
+ version.Ver().Log()
}
func newInfo() pb.ServerInformation {
@@ -80,3 +93,19 @@ func newInfo() pb.ServerInformation {
},
}
}
+
+func setCPUs() {
+ cores := runtime.NumCPU()
+ runtime.GOMAXPROCS(cores)
+ log.Infof("service center is running simultaneously with %d CPU cores",
cores)
+}
+
+func initLogger() {
+ log.SetGlobal(log.Config{
+ LoggerLevel: ServerInfo.Config.LogLevel,
+ LoggerFile: os.ExpandEnv(ServerInfo.Config.LogFilePath),
+ LogFormatText: ServerInfo.Config.LogFormat == "text",
+ LogRotateSize: int(ServerInfo.Config.LogRotateSize),
+ LogBackupCount: int(ServerInfo.Config.LogBackupCount),
+ })
+}
diff --git a/server/core/core.go b/server/core/core.go
index 1b6bf98c..a2aee9a9 100644
--- a/server/core/core.go
+++ b/server/core/core.go
@@ -19,14 +19,11 @@ package core
import (
"flag"
- "fmt"
"github.com/apache/incubator-servicecomb-service-center/pkg/grace"
"github.com/apache/incubator-servicecomb-service-center/pkg/log"
- "github.com/apache/incubator-servicecomb-service-center/pkg/plugin"
"github.com/apache/incubator-servicecomb-service-center/version"
"os"
"os/signal"
- "runtime"
"syscall"
"time"
)
@@ -34,14 +31,9 @@ import (
func Initialize() {
initCommandLine()
+ // initialize configuration
Configure()
- plugin.SetPluginDir(ServerInfo.Config.PluginsDir)
-
- initLogger()
-
- printVersion()
-
go handleSignals()
grace.Init()
@@ -54,35 +46,11 @@ func initCommandLine() {
flag.CommandLine.Parse(os.Args[1:])
if printVer {
- fmt.Printf("ServiceCenter version: %s\n", version.Ver().Version)
- fmt.Printf("Build tag: %s\n", version.Ver().BuildTag)
- fmt.Printf("Go version: %s\n", runtime.Version())
- fmt.Printf("Go OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
+ version.Ver().Print()
os.Exit(0)
}
}
-func printVersion() {
- log.Infof("service center version: %s", version.Ver().Version)
- log.Infof("Build tag: %s", version.Ver().BuildTag)
- log.Infof("Go version: %s", runtime.Version())
- log.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH)
-
- cores := runtime.NumCPU()
- runtime.GOMAXPROCS(cores)
- log.Infof("service center is running simultaneously with %d CPU cores",
cores)
-}
-
-func initLogger() {
- log.SetGlobal(log.Config{
- LoggerLevel: ServerInfo.Config.LogLevel,
- LoggerFile: os.ExpandEnv(ServerInfo.Config.LogFilePath),
- LogFormatText: ServerInfo.Config.LogFormat == "text",
- LogRotateSize: int(ServerInfo.Config.LogRotateSize),
- LogBackupCount: int(ServerInfo.Config.LogBackupCount),
- })
-}
-
func handleSignals() {
defer log.Sync()
diff --git a/server/core/microservice.go b/server/core/microservice.go
index 5e4484cb..47adf688 100644
--- a/server/core/microservice.go
+++ b/server/core/microservice.go
@@ -20,6 +20,7 @@ import (
"github.com/apache/incubator-servicecomb-service-center/pkg/util"
pb
"github.com/apache/incubator-servicecomb-service-center/server/core/proto"
"github.com/apache/incubator-servicecomb-service-center/version"
+ "github.com/astaxie/beego"
"golang.org/x/net/context"
"os"
"strings"
@@ -68,7 +69,7 @@ func prepareSelfRegistration() {
pb.PROP_ALLOW_CROSS_APP: "true",
},
}
- if version.Ver().RunMode == "dev" {
+ if beego.BConfig.RunMode == "dev" {
Service.Environment = pb.ENV_DEV
}
diff --git a/server/core/microservice_test.go b/server/core/microservice_test.go
index d642d641..0ffb8013 100644
--- a/server/core/microservice_test.go
+++ b/server/core/microservice_test.go
@@ -17,20 +17,20 @@ package core
import (
"github.com/apache/incubator-servicecomb-service-center/server/core/proto"
- "github.com/apache/incubator-servicecomb-service-center/version"
+ "github.com/astaxie/beego"
"golang.org/x/net/context"
"os"
"testing"
)
func TestPrepareSelfRegistration(t *testing.T) {
- version.Ver().RunMode = "dev"
+ beego.BConfig.RunMode = "dev"
prepareSelfRegistration()
if Service == nil || Service.Environment != "development" {
t.Fatalf("TestPrepareSelfRegistration faild, %v", Service)
}
- version.Ver().RunMode = "prod"
+ beego.BConfig.RunMode = "prod"
prepareSelfRegistration()
if Service == nil || Service.AppId != "default" || Service.ServiceName
!= "SERVICECENTER" ||
Service.Environment != "production" ||
Service.Properties["allowCrossApp"] != "true" {
diff --git a/server/core/proto/services.go b/server/core/proto/services.go
index 60a3e449..7fd0d38b 100644
--- a/server/core/proto/services.go
+++ b/server/core/proto/services.go
@@ -96,16 +96,16 @@ type ServerConfig struct {
SslVerifyPeer bool `json:"sslVerifyPeer,string"`
SslCiphers string `json:"sslCiphers"`
- AutoSyncInterval string `json:"autoSyncInterval"`
- CompactIndexDelta int64 `json:"compactIndexDelta"`
- CompactInterval string `json:"compactInterval"`
+ AutoSyncInterval string `json:"-"`
+ CompactIndexDelta int64 `json:"-"`
+ CompactInterval string `json:"-"`
EnablePProf bool `json:"-"`
EnableCache bool `json:"-"`
LoggerName string `json:"-"`
- LogRotateSize int64 `json:"logRotateSize"`
- LogBackupCount int64 `json:"logBackupCount"`
+ LogRotateSize int64 `json:"-"`
+ LogBackupCount int64 `json:"-"`
LogFilePath string `json:"-"`
LogLevel string `json:"-"`
LogFormat string `json:"-"`
diff --git a/server/core/swagger/v4.yaml b/server/core/swagger/v4.yaml
index aec7d91f..c7ea633d 100644
--- a/server/core/swagger/v4.yaml
+++ b/server/core/swagger/v4.yaml
@@ -1660,6 +1660,12 @@ definitions:
type: string
buildTag:
type: string
+ goVersion:
+ type: string
+ os:
+ type: string
+ arch:
+ type: string
Properties:
type: object
description: 扩展属性
@@ -2393,7 +2399,7 @@ definitions:
info:
$ref: '#/definitions/Version'
config:
- $ref: '#/definitions/Config'
+ $ref: '#/definitions/Properties'
environments:
$ref: '#/definitions/Properties'
cache:
diff --git a/version/version.go b/version/version.go
index 500363f4..3afc8a32 100644
--- a/version/version.go
+++ b/version/version.go
@@ -16,7 +16,11 @@
*/
package version
-import "github.com/astaxie/beego"
+import (
+ "fmt"
+ "github.com/apache/incubator-servicecomb-service-center/pkg/log"
+ "runtime"
+)
var (
// no need to modify
@@ -28,19 +32,37 @@ var (
)
type VersionSet struct {
- Version string `json:"version"`
- BuildTag string `json:"buildTag"`
- RunMode string `json:"runMode"`
+ Version string `json:"version"`
+ BuildTag string `json:"buildTag"`
+ GoVersion string `json:"goVersion"`
+ OS string `json:"os"`
+ Arch string `json:"arch"`
+}
+
+func (vs *VersionSet) Print() {
+ fmt.Printf("ServiceCenter version: %s\n", versionSet.Version)
+ fmt.Printf("Build tag: %s\n", versionSet.BuildTag)
+ fmt.Printf("Go version: %s\n", versionSet.GoVersion)
+ fmt.Printf("OS/Arch: %s/%s\n", versionSet.OS, versionSet.Arch)
+}
+
+func (vs *VersionSet) Log() {
+ log.Infof("service center version: %s", versionSet.Version)
+ log.Infof("Build tag: %s", versionSet.BuildTag)
+ log.Infof("Go version: %s", versionSet.GoVersion)
+ log.Infof("OS/Arch: %s/%s", versionSet.OS, versionSet.Arch)
}
-var version VersionSet
+var versionSet VersionSet
func init() {
- version.Version = VERSION
- version.BuildTag = BUILD_TAG
- version.RunMode = beego.AppConfig.DefaultString("runmode", "prod")
+ versionSet.Version = VERSION
+ versionSet.BuildTag = BUILD_TAG
+ versionSet.GoVersion = runtime.Version()
+ versionSet.OS = runtime.GOOS
+ versionSet.Arch = runtime.GOARCH
}
func Ver() *VersionSet {
- return &version
+ return &versionSet
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> More information in dump API
> ----------------------------
>
> Key: SCB-797
> URL: https://issues.apache.org/jira/browse/SCB-797
> Project: Apache ServiceComb
> Issue Type: Improvement
> Components: Service-Center
> Reporter: little-cui
> Assignee: little-cui
> Priority: Major
> Fix For: service-center-1.1.0
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)