Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
996d6fe4
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
996d6fe4
编写于
5月 13, 2019
作者:
R
runzexia
提交者:
zryfish
5月 13, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
1270e36c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
36 deletion
+28
-36
cmd/ks-apiserver/app/server.go
cmd/ks-apiserver/app/server.go
+2
-18
cmd/ks-iam/app/server.go
cmd/ks-iam/app/server.go
+2
-18
pkg/server/server.go
pkg/server/server.go
+24
-0
未找到文件。
cmd/ks-apiserver/app/server.go
浏览文件 @
996d6fe4
...
...
@@ -18,7 +18,6 @@
package
app
import
(
"bytes"
goflag
"flag"
"fmt"
"github.com/golang/glog"
...
...
@@ -33,12 +32,12 @@ import (
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/devops"
logging
"kubesphere.io/kubesphere/pkg/models/log"
"kubesphere.io/kubesphere/pkg/server"
"kubesphere.io/kubesphere/pkg/signals"
"kubesphere.io/kubesphere/pkg/simple/client/admin_jenkins"
"kubesphere.io/kubesphere/pkg/simple/client/devops_mysql"
"log"
"net/http"
goRuntime
"runtime"
)
var
jsonIter
=
jsoniter
.
ConfigCompatibleWithStandardLibrary
...
...
@@ -76,7 +75,7 @@ func Run(s *options.ServerRunOptions) error {
container
:=
runtime
.
Container
container
.
DoNotRecover
(
false
)
container
.
Filter
(
filter
.
Logging
)
container
.
RecoverHandler
(
l
ogStackOnRecover
)
container
.
RecoverHandler
(
server
.
L
ogStackOnRecover
)
for
_
,
webservice
:=
range
container
.
RegisteredWebServices
()
{
for
_
,
route
:=
range
webservice
.
Routes
()
{
log
.
Println
(
route
.
Method
,
route
.
Path
)
...
...
@@ -197,18 +196,3 @@ func waitForResourceSync() {
log
.
Println
(
"resources sync success"
)
}
func
logStackOnRecover
(
panicReason
interface
{},
httpWriter
http
.
ResponseWriter
)
{
var
buffer
bytes
.
Buffer
buffer
.
WriteString
(
fmt
.
Sprintf
(
"recover from panic situation: - %v
\r\n
"
,
panicReason
))
for
i
:=
2
;
;
i
+=
1
{
_
,
file
,
line
,
ok
:=
goRuntime
.
Caller
(
i
)
if
!
ok
{
break
}
buffer
.
WriteString
(
fmt
.
Sprintf
(
" %s:%d
\r\n
"
,
file
,
line
))
}
glog
.
Error
(
buffer
.
String
())
httpWriter
.
WriteHeader
(
http
.
StatusInternalServerError
)
httpWriter
.
Write
([]
byte
(
"recover from panic situation"
))
}
cmd/ks-iam/app/server.go
浏览文件 @
996d6fe4
...
...
@@ -18,7 +18,6 @@
package
app
import
(
"bytes"
goflag
"flag"
"fmt"
"github.com/golang/glog"
...
...
@@ -29,13 +28,13 @@ import (
"kubesphere.io/kubesphere/pkg/filter"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/iam"
"kubesphere.io/kubesphere/pkg/server"
"kubesphere.io/kubesphere/pkg/signals"
"kubesphere.io/kubesphere/pkg/simple/client/admin_jenkins"
"kubesphere.io/kubesphere/pkg/simple/client/devops_mysql"
"kubesphere.io/kubesphere/pkg/utils/jwtutil"
"log"
"net/http"
goRuntime
"runtime"
"time"
)
...
...
@@ -86,7 +85,7 @@ func Run(s *options.ServerRunOptions) error {
container
:=
runtime
.
Container
container
.
Filter
(
filter
.
Logging
)
container
.
DoNotRecover
(
false
)
container
.
RecoverHandler
(
l
ogStackOnRecover
)
container
.
RecoverHandler
(
server
.
L
ogStackOnRecover
)
for
_
,
webservice
:=
range
container
.
RegisteredWebServices
()
{
for
_
,
route
:=
range
webservice
.
Routes
()
{
...
...
@@ -136,18 +135,3 @@ func initializeAdminJenkins() {
func
initializeDevOpsDatabase
()
{
devops_mysql
.
OpenDatabase
()
}
func
logStackOnRecover
(
panicReason
interface
{},
httpWriter
http
.
ResponseWriter
)
{
var
buffer
bytes
.
Buffer
buffer
.
WriteString
(
fmt
.
Sprintf
(
"recover from panic situation: - %v
\r\n
"
,
panicReason
))
for
i
:=
2
;
;
i
+=
1
{
_
,
file
,
line
,
ok
:=
goRuntime
.
Caller
(
i
)
if
!
ok
{
break
}
buffer
.
WriteString
(
fmt
.
Sprintf
(
" %s:%d
\r\n
"
,
file
,
line
))
}
glog
.
Error
(
buffer
.
String
())
httpWriter
.
WriteHeader
(
http
.
StatusInternalServerError
)
httpWriter
.
Write
([]
byte
(
"recover from panic situation"
))
}
pkg/server/server.go
0 → 100644
浏览文件 @
996d6fe4
package
server
import
(
"bytes"
"fmt"
"github.com/golang/glog"
"net/http"
"runtime"
)
func
LogStackOnRecover
(
panicReason
interface
{},
httpWriter
http
.
ResponseWriter
)
{
var
buffer
bytes
.
Buffer
buffer
.
WriteString
(
fmt
.
Sprintf
(
"recover from panic situation: - %v
\r\n
"
,
panicReason
))
for
i
:=
2
;
;
i
+=
1
{
_
,
file
,
line
,
ok
:=
runtime
.
Caller
(
i
)
if
!
ok
{
break
}
buffer
.
WriteString
(
fmt
.
Sprintf
(
" %s:%d
\r\n
"
,
file
,
line
))
}
glog
.
Error
(
buffer
.
String
())
httpWriter
.
WriteHeader
(
http
.
StatusInternalServerError
)
httpWriter
.
Write
([]
byte
(
"recover from panic situation"
))
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录