Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
ficus_clientserver
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yunpeng.song
ficus_clientserver
Commits
1c5665a0
Commit
1c5665a0
authored
Nov 18, 2019
by
yunpeng.song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加shedule http 接口
parent
2e3a72ce
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
2 deletions
+32
-2
cfg.json
+2
-1
config/config.go
+1
-0
config/loadconfig.go
+5
-0
log.go
+1
-1
work.go
+23
-0
No files found.
cfg.json
View file @
1c5665a0
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
},
},
"thriftport"
:
{
"thriftport"
:
{
"loginserver"
:
"9090"
,
"loginserver"
:
"9090"
,
"multserver"
:
"9091"
"multserver"
:
"9091"
,
"httpserver"
:
"9081"
},
},
"eurekakey"
:
{
"eurekakey"
:
{
"device"
:
"dispatchserver"
"device"
:
"dispatchserver"
...
...
config/config.go
View file @
1c5665a0
...
@@ -37,6 +37,7 @@ type (
...
@@ -37,6 +37,7 @@ type (
ServerPortCFG
struct
{
ServerPortCFG
struct
{
LoginServer
string
`json:"loginserver"`
// 消息推送服务端口
LoginServer
string
`json:"loginserver"`
// 消息推送服务端口
MultServer
string
`json:"multserver"`
// 多服务复用端口
MultServer
string
`json:"multserver"`
// 多服务复用端口
HttpServer
string
`json:"httpserver"`
// http 服务端口
}
}
HeartTime
struct
{
HeartTime
struct
{
...
...
config/loadconfig.go
View file @
1c5665a0
...
@@ -170,6 +170,11 @@ func GetMultServerPort() string {
...
@@ -170,6 +170,11 @@ func GetMultServerPort() string {
return
net
.
JoinHostPort
(
""
,
ThriftPort
.
MultServer
)
return
net
.
JoinHostPort
(
""
,
ThriftPort
.
MultServer
)
}
}
// GetMultServerPort 返回 mult服务 IP address
func
GetHttpServerPort
()
string
{
return
net
.
JoinHostPort
(
""
,
ThriftPort
.
HttpServer
)
}
//GetClientMaxLostTimes 返回client maxlosttimes
//GetClientMaxLostTimes 返回client maxlosttimes
func
GetClientMaxLostTimes
()
int
{
func
GetClientMaxLostTimes
()
int
{
return
Client
.
MaxLostTimes
return
Client
.
MaxLostTimes
...
...
log.go
View file @
1c5665a0
...
@@ -29,7 +29,7 @@ func InitLog() {
...
@@ -29,7 +29,7 @@ func InitLog() {
logName
+
".%Y-%m-%d-%H-%M.log"
,
logName
+
".%Y-%m-%d-%H-%M.log"
,
rotatelogs
.
WithLinkName
(
logName
),
// 生成软链,指向最新日志文件
rotatelogs
.
WithLinkName
(
logName
),
// 生成软链,指向最新日志文件
rotatelogs
.
WithMaxAge
(
30
*
24
*
time
.
Hour
),
// 文件最大保存时间
rotatelogs
.
WithMaxAge
(
30
*
24
*
time
.
Hour
),
// 文件最大保存时间
rotatelogs
.
WithRotationTime
(
2
*
time
.
Hour
),
// 日志切割时间间隔
rotatelogs
.
WithRotationTime
(
4
*
time
.
Hour
),
// 日志切割时间间隔
//rotatelogs.WithRotationTime(1*time.Minute),
//rotatelogs.WithRotationTime(1*time.Minute),
)
)
writeMap
:=
lfshook
.
WriterMap
{
writeMap
:=
lfshook
.
WriterMap
{
...
...
work.go
View file @
1c5665a0
...
@@ -15,6 +15,7 @@ import (
...
@@ -15,6 +15,7 @@ import (
"ficus_clientserver/nethandle/thriftservice"
"ficus_clientserver/nethandle/thriftservice"
"ficus_clientserver/tool"
"ficus_clientserver/tool"
"fmt"
"fmt"
"net/http"
"os"
"os"
"os/exec"
"os/exec"
"runtime/debug"
"runtime/debug"
...
@@ -127,6 +128,7 @@ func StartThrift() {
...
@@ -127,6 +128,7 @@ func StartThrift() {
go
StartThriftSever1
()
go
StartThriftSever1
()
go
StartThriftSever2
()
go
StartThriftSever2
()
go
StartClientHeartWork
()
go
StartClientHeartWork
()
go
StartHttpServer
()
}
}
// StartClientHeartWork 开始循环心跳工作
// StartClientHeartWork 开始循环心跳工作
...
@@ -249,3 +251,24 @@ func StartThriftSever2() {
...
@@ -249,3 +251,24 @@ func StartThriftSever2() {
log
.
Panicln
(
err
)
log
.
Panicln
(
err
)
}
}
}
}
func
StartHttpServer
()
{
scheduleHandle
:=
thriftservice
.
NewScheduleHandle
(
MsgControl
,
ClientManager
)
scheduleProcessor
:=
native
.
NewScheduleServiceProcessor
(
scheduleHandle
)
scheduleProtocolFactory
:=
thrift
.
NewTJSONProtocolFactory
()
scheduleHandler
:=
thrift
.
NewThriftHandlerFunc
(
scheduleProcessor
,
scheduleProtocolFactory
,
scheduleProtocolFactory
)
mux
:=
http
.
NewServeMux
()
mux
.
HandleFunc
(
"/schedule"
,
MiddleHandle
(
http
.
HandlerFunc
(
scheduleHandler
)))
http
.
ListenAndServe
(
config
.
GetHttpServerPort
(),
mux
)
}
func
MiddleHandle
(
next
http
.
Handler
)
http
.
HandlerFunc
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Header
()
.
Set
(
"Access-Control-Allow-Origin"
,
"*"
)
//允许访问所有域
w
.
Header
()
.
Set
(
"Access-Control-Allow-Headers"
,
"*"
)
//w.Header().Add("Access-Control-Allow-Headers", "Content-Type") //header的类型
w
.
Header
()
.
Set
(
"content-type"
,
"application/json"
)
//返回数据格式是json
w
.
Header
()
.
Set
(
"Access-Control-Allow-Methods"
,
"*"
)
next
.
ServeHTTP
(
w
,
r
)
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment