Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
884e61cc
Commit
884e61cc
authored
Sep 10, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify configuration
parent
fadcc00a
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
350 additions
and
119 deletions
+350
-119
config.go
echo/client/app/config.go
+52
-2
main.go
echo/client/app/main.go
+13
-27
utils.go
echo/client/app/utils.go
+0
-1
load.sh
echo/client/assembly/bin/load.sh
+1
-1
app.properties
echo/client/assembly/common/app.properties
+1
-1
release.sh
echo/client/assembly/linux/release.sh
+0
-29
release.sh
echo/client/assembly/windows/release.sh
+0
-29
test.sh
echo/client/assembly/windows/test.sh
+1
-1
config.toml
echo/client/profiles/test/config.toml
+24
-0
echo_client-0.3.04-20160910-1539-test.tar.gz
...rget/windows/echo_client-0.3.04-20160910-1539-test.tar.gz
+0
-0
load.sh
...windows/echo_client-0.3.04-20160910-1539-test/bin/load.sh
+132
-0
config.toml
...ws/echo_client-0.3.04-20160910-1539-test/conf/config.toml
+44
-0
echo_client.exe
...cho_client-0.3.04-20160910-1539-test/sbin/echo_client.exe
+0
-0
config.go
echo/server/app/config.go
+47
-0
handler.go
echo/server/app/handler.go
+1
-1
server.go
echo/server/app/server.go
+13
-26
app.properties
echo/server/assembly/common/app.properties
+1
-1
config.toml
echo/server/profiles/test/config.toml
+20
-0
No files found.
echo/client/app/config.go
View file @
884e61cc
...
...
@@ -32,24 +32,54 @@ var (
)
type
(
GettySessionParam
struct
{
TcpNoDelay
bool
`default:"true"`
TcpKeepAlive
bool
`default:"true"`
TcpRBufSize
int
`default:"262144"`
TcpWBufSize
int
`default:"65536"`
PkgRQSize
int
`default:"1024"`
PkgWQSize
int
`default:"1024"`
TcpReadTimeout
string
`default:"1s"`
tcpReadTimeout
time
.
Duration
TcpWriteTimeout
string
`default:"5s"`
tcpWriteTimeout
time
.
Duration
WaitTimeout
string
`default:"7s"`
waitTimeout
time
.
Duration
SessionName
string
`default:"echo-client"`
}
// Config holds supported types by the multiconfig package
Config
struct
{
LocalHost
string
`default:"127.0.0.1"`
LocalHost
string
`default:"127.0.0.1"`
// server
ServerHost
string
`default:"127.0.0.1"`
ServerPort
int
`default:"10000"`
ProfilePort
int
`default:"10086"`
// session pool
ConnectionNum
int
`default:"16"`
ConnectInterval
string
`default:"5s"`
connectInterval
time
.
Duration
// heartbeat
HeartbeatPeriod
string
`default:"15s"`
heartbeatPeriod
time
.
Duration
// session
SessionTimeout
string
`default:"60s"`
sessionTimeout
time
.
Duration
EchoTimes
int
`default:"10"`
// echo
EchoString
string
`default:"hello"`
EchoTimes
int
`default:"10"`
// app
FailFastTimeout
string
`default:"5s"`
failFastTimeout
time
.
Duration
// session tcp parameters
GettySessionParam
GettySessionParam
`required:"true"`
}
)
...
...
@@ -86,6 +116,26 @@ func initConf() {
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(SessionTimeout{%#v}) = error{%v}"
,
conf
.
SessionTimeout
,
err
))
return
}
conf
.
failFastTimeout
,
err
=
time
.
ParseDuration
(
conf
.
FailFastTimeout
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(FailFastTimeout{%#v}) = error{%v}"
,
conf
.
FailFastTimeout
,
err
))
return
}
conf
.
GettySessionParam
.
tcpReadTimeout
,
err
=
time
.
ParseDuration
(
conf
.
GettySessionParam
.
TcpReadTimeout
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(TcpReadTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
TcpReadTimeout
,
err
))
return
}
conf
.
GettySessionParam
.
tcpWriteTimeout
,
err
=
time
.
ParseDuration
(
conf
.
GettySessionParam
.
TcpWriteTimeout
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(TcpWriteTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
TcpWriteTimeout
,
err
))
return
}
conf
.
GettySessionParam
.
waitTimeout
,
err
=
time
.
ParseDuration
(
conf
.
GettySessionParam
.
WaitTimeout
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
return
}
gocolor
.
Info
(
"config{%#v}
\n
"
,
conf
)
...
...
echo/client/app/main.go
View file @
884e61cc
...
...
@@ -30,21 +30,7 @@ import (
)
const
(
tcpRBufSize
=
256
*
1024
tcpWBufSize
=
64
*
1024
pkgRQSize
=
1024
pkgWQSize
=
64
tcpReadTimeout
=
1e9
tcpWriteTimeout
=
5e9
waitTimeout
=
5e9
// 5s
echoSessionTimeout
=
5e9
maxSessionNum
=
100
sessionName
=
"echo-client"
)
const
(
survivalTimeout
=
3e9
pprofPath
=
"/debug/pprof/"
pprofPath
=
"/debug/pprof/"
)
var
(
...
...
@@ -89,20 +75,20 @@ func newSession(session *getty.Session) error {
panic
(
fmt
.
Sprintf
(
"%s, session.conn{%#v} is not tcp connection
\n
"
,
session
.
Stat
(),
session
.
Conn
()))
}
tcpConn
.
SetNoDelay
(
true
)
tcpConn
.
Set
ReadBuffer
(
tcpRBufSiz
e
)
tcpConn
.
Set
WriteBuffer
(
tcpW
BufSize
)
tcpConn
.
Set
KeepAlive
(
tru
e
)
tcpConn
.
SetNoDelay
(
conf
.
GettySessionParam
.
TcpNoDelay
)
tcpConn
.
Set
KeepAlive
(
conf
.
GettySessionParam
.
TcpKeepAliv
e
)
tcpConn
.
Set
ReadBuffer
(
conf
.
GettySessionParam
.
TcpR
BufSize
)
tcpConn
.
Set
WriteBuffer
(
conf
.
GettySessionParam
.
TcpWBufSiz
e
)
session
.
SetName
(
s
essionName
)
session
.
SetName
(
conf
.
GettySessionParam
.
S
essionName
)
session
.
SetPkgHandler
(
NewEchoPackageHandler
())
session
.
SetEventListener
(
newEchoMessageHandler
())
session
.
SetRQLen
(
p
kgRQSize
)
session
.
SetWQLen
(
p
kgWQSize
)
session
.
SetReadDeadline
(
tcpReadTimeout
)
session
.
SetWriteDeadline
(
tcpWriteTimeout
)
session
.
SetRQLen
(
conf
.
GettySessionParam
.
P
kgRQSize
)
session
.
SetWQLen
(
conf
.
GettySessionParam
.
P
kgWQSize
)
session
.
SetReadDeadline
(
conf
.
GettySessionParam
.
tcpReadTimeout
)
session
.
SetWriteDeadline
(
conf
.
GettySessionParam
.
tcpWriteTimeout
)
session
.
SetCronPeriod
((
int
)(
conf
.
heartbeatPeriod
.
Nanoseconds
()
/
1e6
))
session
.
SetWaitTime
(
waitTimeout
)
session
.
SetWaitTime
(
conf
.
GettySessionParam
.
waitTimeout
)
log
.
Debug
(
"client new session:%s
\n
"
,
session
.
Stat
())
return
nil
...
...
@@ -132,7 +118,7 @@ func initSignal() {
case
syscall
.
SIGHUP
:
// reload()
default
:
go
time
.
AfterFunc
(
survival
Timeout
,
func
()
{
go
time
.
AfterFunc
(
conf
.
failFast
Timeout
,
func
()
{
log
.
Warn
(
"app exit now by force..."
)
os
.
Exit
(
1
)
})
...
...
@@ -152,7 +138,7 @@ func echo() {
pkg
.
H
.
Sequence
=
atomic
.
AddUint32
(
&
reqID
,
1
)
// pkg.H.ServiceID = 0
pkg
.
H
.
Command
=
echoCmd
pkg
.
B
=
echoMessage
pkg
.
B
=
conf
.
EchoString
pkg
.
H
.
Len
=
(
uint16
)(
len
(
pkg
.
B
))
if
session
:=
client
.
selectSession
();
session
!=
nil
{
...
...
echo/client/app/utils.go
View file @
884e61cc
...
...
@@ -51,7 +51,6 @@ const (
echoHeartbeatRequestString
=
"ping"
echoHeartbeatResponseString
=
"pong"
echoMessage
=
"Hello, getty!"
)
var
(
...
...
echo/client/assembly/bin/load.sh
View file @
884e61cc
...
...
@@ -32,7 +32,7 @@ usage() {
}
start
()
{
APP_LOG_PATH
=
"
${
PROJECT_HOME
}
logs/"
APP_LOG_PATH
=
${
PROJECT_HOME
}
"
logs/"
mkdir
-p
${
APP_LOG_PATH
}
APP_BIN
=
${
PROJECT_HOME
}
sbin/
${
APP_NAME
}
chmod
u+x
${
APP_BIN
}
...
...
echo/client/assembly/common/app.properties
View file @
884e61cc
#
dubbogo
application configure script
#
getty
application configure script
# ******************************************************
# DESC : application environment variable
# AUTHOR : Alex Stocks
...
...
echo/client/assembly/linux/release.sh
deleted
100644 → 0
View file @
fadcc00a
#!/usr/bin/env bash
# ******************************************************
# DESC : build script for release env
# AUTHOR : Alex Stocks
# VERSION : 1.0
# LICENCE : LGPL V3
# EMAIL : alexstocks@foxmail.com
# MOD : 2016-07-12 16:25
# FILE : release.sh
# ******************************************************
set
-e
export
GOOS
=
linux
export
GOARCH
=
amd64
PROFILE
=
release
PROJECT_HOME
=
`
pwd
`
if
[
-f
"
${
PROJECT_HOME
}
/assembly/common/app.properties"
]
;
then
.
${
PROJECT_HOME
}
/assembly/common/app.properties
fi
if
[
-f
"
${
PROJECT_HOME
}
/assembly/common/build.sh"
]
;
then
.
${
PROJECT_HOME
}
/assembly/common/build.sh
fi
echo/client/assembly/windows/release.sh
deleted
100644 → 0
View file @
fadcc00a
#!/usr/bin/env bash
# ******************************************************
# DESC : build script for release env
# AUTHOR : Alex Stocks
# VERSION : 1.0
# LICENCE : LGPL V3
# EMAIL : alexstocks@foxmail.com
# MOD : 2016-07-12 16:25
# FILE : release.sh
# ******************************************************
set
-e
export
GOOS
=
windows
export
GOARCH
=
amd64
PROFILE
=
release
PROJECT_HOME
=
`
pwd
`
if
[
-f
"
${
PROJECT_HOME
}
/assembly/common/app.properties"
]
;
then
.
${
PROJECT_HOME
}
/assembly/common/app.properties
fi
if
[
-f
"
${
PROJECT_HOME
}
/assembly/common/build.sh"
]
;
then
.
${
PROJECT_HOME
}
/assembly/common/build.sh
fi
echo/client/assembly/windows/test.sh
View file @
884e61cc
...
...
@@ -3,7 +3,7 @@
# DESC : build script for test env
# AUTHOR : Alex Stocks
# VERSION : 1.0
# LICENCE :
LGPL V3
# LICENCE :
Apache License 2.0
# EMAIL : alexstocks@foxmail.com
# MOD : 2016-07-12 16:34
# FILE : test.sh
...
...
echo/client/profiles/test/config.toml
View file @
884e61cc
# toml configure file
# toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写
# host
LocalHost
=
"127.0.0.1"
# server
ServerHost
=
"192.168.35.1"
ServerPort
=
10000
ProfilePort
=
10080
# connection pool
# 连接池连接数目
ConnectionNum
=
2
# 当连接失败或者连接断开时,连接池中重连的间隔时间
ConnectInterval
=
"5s"
# session
# client与server之间连接的心跳周期
HeartbeatPeriod
=
"10s"
# client与server之间连接的超时时间
SessionTimeout
=
"20s"
# client
# client echo request string
EchoString
=
"Hello, getty!"
# 发送echo请求次数
EchoTimes
=
100000
# app fail fast
FailFastTimeout
=
"3s"
# tcp
[GettySessionParam]
TcpNoDelay
=
true
TcpKeepAlive
=
true
TcpRBufSize
=
262144
TcpWBufSize
=
65536
PkgRQSize
=
512
PkgWQSize
=
256
TcpReadTimeout
=
1e9
TcpWriteTimeout
=
5e9
WaitTimeout
=
1e9
//
1
s
SessionName
=
"echo-client"
echo/client/target/windows/echo_client-0.3.04-20160910-1539-test.tar.gz
0 → 100644
View file @
884e61cc
File added
echo/client/target/windows/echo_client-0.3.04-20160910-1539-test/bin/load.sh
0 → 100644
View file @
884e61cc
#!/usr/bin/env bash
# ******************************************************
# DESC : getty app devops script
# AUTHOR : Alex Stocks
# VERSION : 1.0
# LICENCE : LGPL V3
# EMAIL : alexstocks@foxmail.com
# MOD : 2016-05-13 02:01
# FILE : load.sh
# ******************************************************
APP_NAME
=
"echo_client"
APP_ARGS
=
""
PROJECT_HOME
=
""
OS_NAME
=
`
uname
`
if
[[
${
OS_NAME
}
==
"Linux"
]]
;
then
PROJECT_HOME
=
`
pwd
`
PROJECT_HOME
=
${
PROJECT_HOME
}
"/"
fi
export
APP_CONF_FILE
=
${
PROJECT_HOME
}
"conf/config.toml"
export
APP_LOG_CONF_FILE
=
${
PROJECT_HOME
}
"conf/log.xml"
usage
()
{
echo
"Usage:
$0
start"
echo
"
$0
stop"
echo
"
$0
term"
echo
"
$0
restart"
echo
"
$0
list"
exit
}
start
()
{
APP_LOG_PATH
=
${
PROJECT_HOME
}
"logs/"
mkdir
-p
${
APP_LOG_PATH
}
APP_BIN
=
${
PROJECT_HOME
}
sbin/
${
APP_NAME
}
chmod
u+x
${
APP_BIN
}
# CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &"
CMD
=
"
${
APP_BIN
}
"
eval
${
CMD
}
PID
=
`
ps aux |
grep
-w
${
APP_NAME
}
|
grep
-v
grep
|
awk
'{print $2}'
`
if
[[
${
OS_NAME
}
!=
"Linux"
]]
;
then
PID
=
`
ps aux |
grep
-w
${
APP_NAME
}
|
grep
-v
grep
|
awk
'{print $1}'
`
fi
if
[
"
${
PID
}
"
!=
""
]
;
then
for
p
in
${
PID
}
do
echo
"start
${
APP_NAME
}
( pid ="
${
p
}
")"
done
fi
}
stop
()
{
PID
=
`
ps aux |
grep
-w
${
APP_NAME
}
|
grep
-v
grep
|
awk
'{print $2}'
`
if
[[
${
OS_NAME
}
!=
"Linux"
]]
;
then
PID
=
`
ps aux |
grep
-w
${
APP_NAME
}
|
grep
-v
grep
|
awk
'{print $1}'
`
fi
if
[
"
${
PID
}
"
!=
""
]
;
then
for
ps
in
${
PID
}
do
echo
"kill -SIGINT
${
APP_NAME
}
( pid ="
${
ps
}
")"
kill
-2
${
ps
}
done
fi
}
term
()
{
PID
=
`
ps aux |
grep
-w
${
APP_NAME
}
|
grep
-v
grep
|
awk
'{print $2}'
`
if
[[
${
OS_NAME
}
!=
"Linux"
]]
;
then
PID
=
`
ps aux |
grep
-w
${
APP_NAME
}
|
grep
-v
grep
|
awk
'{print $1}'
`
fi
if
[
"
${
PID
}
"
!=
""
]
;
then
for
ps
in
${
PID
}
do
echo
"kill -9
${
APP_NAME
}
( pid ="
${
ps
}
")"
kill
-9
${
ps
}
done
fi
}
list
()
{
PID
=
`
ps aux |
grep
-w
${
APP_NAME
}
|
grep
-v
grep
|
awk
'{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'
`
if
[[
${
OS_NAME
}
!=
"Linux"
]]
;
then
PID
=
`
ps aux |
grep
-w
${
APP_NAME
}
|
grep
-v
grep
|
awk
'{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'
`
fi
if
[
"
${
PID
}
"
!=
""
]
;
then
echo
"list
${
APP_NAME
}
"
if
[[
${
OS_NAME
}
==
"Linux"
]]
;
then
echo
"index: user, pid, start, duration"
else
echo
"index: PID, WINPID, UID, STIME, COMMAND"
fi
idx
=
0
for
ps
in
${
PID
}
do
echo
"
${
idx
}
:
${
ps
}
"
((
idx ++
))
done
fi
}
opt
=
$1
case
C
"
$opt
"
in
Cstart
)
start
;;
Cstop
)
stop
;;
Cterm
)
term
;;
Crestart
)
term
start
;;
Clist
)
list
;;
C
*
)
usage
;;
esac
echo/client/target/windows/echo_client-0.3.04-20160910-1539-test/conf/config.toml
0 → 100644
View file @
884e61cc
# toml configure file
# toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写
# host
LocalHost
=
"127.0.0.1"
# server
ServerHost
=
"192.168.35.1"
ServerPort
=
10000
ProfilePort
=
10080
# connection pool
# 连接池连接数目
ConnectionNum
=
2
# 当连接失败或者连接断开时,连接池中重连的间隔时间
ConnectInterval
=
"5s"
# session
# client与server之间连接的心跳周期
HeartbeatPeriod
=
"10s"
# client与server之间连接的超时时间
SessionTimeout
=
"20s"
# client
# client echo request string
EchoString
=
"Hello, getty!"
# 发送echo请求次数
EchoTimes
=
100000
# app fail fast
FailFastTimeout
=
"3s"
# tcp
[GettySessionParam]
TcpNoDelay
=
true
TcpKeepAlive
=
true
TcpRBufSize
=
262144
TcpWBufSize
=
65536
PkgRQSize
=
512
PkgWQSize
=
256
TcpReadTimeout
=
1e9
TcpWriteTimeout
=
5e9
WaitTimeout
=
1e9
//
1
s
SessionName
=
"echo-client"
echo/client/target/windows/echo_client-0.3.04-20160910-1539-test/sbin/echo_client.exe
0 → 100644
View file @
884e61cc
File added
echo/server/app/config.go
View file @
884e61cc
...
...
@@ -32,14 +32,40 @@ var (
)
type
(
GettySessionParam
struct
{
TcpNoDelay
bool
`default:"true"`
TcpKeepAlive
bool
`default:"true"`
TcpRBufSize
int
`default:"262144"`
TcpWBufSize
int
`default:"65536"`
PkgRQSize
int
`default:"1024"`
PkgWQSize
int
`default:"1024"`
TcpReadTimeout
string
`default:"1s"`
tcpReadTimeout
time
.
Duration
TcpWriteTimeout
string
`default:"5s"`
tcpWriteTimeout
time
.
Duration
WaitTimeout
string
`default:"7s"`
waitTimeout
time
.
Duration
SessionName
string
`default:"echo-client"`
}
// Config holds supported types by the multiconfig package
Config
struct
{
// local address
Host
string
`default:"127.0.0.1"`
Ports
[]
string
`default:["10000"]`
ProfilePort
int
`default:"10086"`
// session
SessionTimeout
string
`default:"60s"`
sessionTimeout
time
.
Duration
SessionNumber
int
`default:"1000"`
// app
FailFastTimeout
string
`default:"5s"`
failFastTimeout
time
.
Duration
// session tcp parameters
GettySessionParam
GettySessionParam
`required:"true"`
}
)
...
...
@@ -66,6 +92,27 @@ func initConf() {
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(SessionTimeout{%#v}) = error{%v}"
,
conf
.
SessionTimeout
,
err
))
return
}
conf
.
failFastTimeout
,
err
=
time
.
ParseDuration
(
conf
.
FailFastTimeout
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(FailFastTimeout{%#v}) = error{%v}"
,
conf
.
FailFastTimeout
,
err
))
return
}
conf
.
GettySessionParam
.
tcpReadTimeout
,
err
=
time
.
ParseDuration
(
conf
.
GettySessionParam
.
TcpReadTimeout
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(TcpReadTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
TcpReadTimeout
,
err
))
return
}
conf
.
GettySessionParam
.
tcpWriteTimeout
,
err
=
time
.
ParseDuration
(
conf
.
GettySessionParam
.
TcpWriteTimeout
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(TcpWriteTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
TcpWriteTimeout
,
err
))
return
}
conf
.
GettySessionParam
.
waitTimeout
,
err
=
time
.
ParseDuration
(
conf
.
GettySessionParam
.
WaitTimeout
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
return
}
gocolor
.
Info
(
"config{%#v}
\n
"
,
conf
)
// log
...
...
echo/server/app/handler.go
View file @
884e61cc
...
...
@@ -87,7 +87,7 @@ func (this *EchoMessageHandler) OnOpen(session *getty.Session) error {
)
this
.
rwlock
.
RLock
()
if
maxSessionNum
<
len
(
this
.
sessionMap
)
{
if
conf
.
SessionNumber
<
len
(
this
.
sessionMap
)
{
err
=
errTooManySessions
}
this
.
rwlock
.
RUnlock
()
...
...
echo/server/app/server.go
View file @
884e61cc
...
...
@@ -28,21 +28,7 @@ import (
)
const
(
tcpRBufSize
=
256
*
1024
tcpWBufSize
=
64
*
1024
pkgRQSize
=
1024
pkgWQSize
=
64
tcpReadTimeout
=
1e9
tcpWriteTimeout
=
5e9
waitTimeout
=
5e9
// 5s
echoSessionTimeout
=
5e9
maxSessionNum
=
100
sessionName
=
"echo-server"
)
const
(
survivalTimeout
=
3e9
pprofPath
=
"/debug/pprof/"
pprofPath
=
"/debug/pprof/"
)
var
(
...
...
@@ -92,19 +78,20 @@ func newSession(session *getty.Session) error {
panic
(
fmt
.
Sprintf
(
"%s, session.conn{%#v} is not tcp connection
\n
"
,
session
.
Stat
(),
session
.
Conn
()))
}
tcpConn
.
SetNoDelay
(
true
)
tcpConn
.
Set
ReadBuffer
(
tcpRBufSiz
e
)
tcpConn
.
Set
WriteBuffer
(
tcpW
BufSize
)
tcpConn
.
Set
KeepAlive
(
tru
e
)
tcpConn
.
SetNoDelay
(
conf
.
GettySessionParam
.
TcpNoDelay
)
tcpConn
.
Set
KeepAlive
(
conf
.
GettySessionParam
.
TcpKeepAliv
e
)
tcpConn
.
Set
ReadBuffer
(
conf
.
GettySessionParam
.
TcpR
BufSize
)
tcpConn
.
Set
WriteBuffer
(
conf
.
GettySessionParam
.
TcpWBufSiz
e
)
session
.
SetName
(
s
essionName
)
session
.
SetName
(
conf
.
GettySessionParam
.
S
essionName
)
session
.
SetPkgHandler
(
NewEchoPackageHandler
())
session
.
SetEventListener
(
newEchoMessageHandler
())
session
.
SetRQLen
(
pkgRQSize
)
session
.
SetWQLen
(
pkgWQSize
)
session
.
SetReadDeadline
(
tcpReadTimeout
)
session
.
SetWriteDeadline
(
tcpWriteTimeout
)
session
.
SetWaitTime
(
waitTimeout
)
session
.
SetRQLen
(
conf
.
GettySessionParam
.
PkgRQSize
)
session
.
SetWQLen
(
conf
.
GettySessionParam
.
PkgWQSize
)
session
.
SetReadDeadline
(
conf
.
GettySessionParam
.
tcpReadTimeout
)
session
.
SetWriteDeadline
(
conf
.
GettySessionParam
.
tcpWriteTimeout
)
session
.
SetCronPeriod
((
int
)(
conf
.
sessionTimeout
.
Nanoseconds
()
/
1e6
))
session
.
SetWaitTime
(
conf
.
GettySessionParam
.
waitTimeout
)
log
.
Debug
(
"app accepts new session:%s
\n
"
,
session
.
Stat
())
return
nil
...
...
@@ -165,7 +152,7 @@ func initSignal() {
case
syscall
.
SIGHUP
:
// reload()
default
:
go
time
.
AfterFunc
(
survival
Timeout
,
func
()
{
go
time
.
AfterFunc
(
conf
.
failFast
Timeout
,
func
()
{
log
.
Warn
(
"app exit now by force..."
)
os
.
Exit
(
1
)
})
...
...
echo/server/assembly/common/app.properties
View file @
884e61cc
#
dubbogo
application configure script
#
getty
application configure script
# ******************************************************
# DESC : application environment variable
# AUTHOR : Alex Stocks
...
...
echo/server/profiles/test/config.toml
View file @
884e61cc
# toml configure file
# toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写
# Host = "127.0.0.1"
Host
=
"192.168.35.1"
Ports
=
[
"10000"
,
"20000"
]
ProfilePort
=
10086
# session
# client与server之间连接的超时时间
SessionTimeout
=
"20s"
SessionNumber
=
700
# app
FailFastTimeout
=
"3s"
# tcp
[GettySessionParam]
TcpNoDelay
=
true
TcpKeepAlive
=
true
TcpRBufSize
=
262144
TcpWBufSize
=
524288
PkgRQSize
=
1024
PkgWQSize
=
512
TcpReadTimeout
=
1e9
TcpWriteTimeout
=
5e9
WaitTimeout
=
1e9
//
1
s
SessionName
=
"echo-server"
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