Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
d56491ab
Commit
d56491ab
authored
May 20, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync beeApp.Server to graceful
parent
9fd7acf6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
app.go
app.go
+7
-4
grace.go
grace/grace.go
+2
-2
No files found.
app.go
View file @
d56491ab
...
...
@@ -78,15 +78,19 @@ func (app *App) Run() {
}
}
else
{
if
Graceful
{
app
.
Server
.
Addr
=
addr
app
.
Server
.
Handler
=
app
.
Handlers
app
.
Server
.
ReadTimeout
=
time
.
Duration
(
HttpServerTimeOut
)
*
time
.
Second
app
.
Server
.
WriteTimeout
=
time
.
Duration
(
HttpServerTimeOut
)
*
time
.
Second
if
EnableHttpTLS
{
go
func
()
{
time
.
Sleep
(
20
*
time
.
Microsecond
)
if
HttpsPort
!=
0
{
addr
=
fmt
.
Sprintf
(
"%s:%d"
,
HttpAddr
,
HttpsPort
)
app
.
Server
.
Addr
=
addr
}
server
:=
grace
.
NewServer
(
addr
,
app
.
Handlers
)
server
.
Server
.
ReadTimeout
=
time
.
Duration
(
HttpServerTimeOut
)
*
time
.
Second
server
.
Server
.
WriteTimeout
=
time
.
Duration
(
HttpServerTimeOut
)
*
time
.
Second
server
.
Server
=
app
.
Server
err
:=
server
.
ListenAndServeTLS
(
HttpCertFile
,
HttpKeyFile
)
if
err
!=
nil
{
BeeLogger
.
Critical
(
"ListenAndServeTLS: "
,
err
)
...
...
@@ -98,8 +102,7 @@ func (app *App) Run() {
if
EnableHttpListen
{
go
func
()
{
server
:=
grace
.
NewServer
(
addr
,
app
.
Handlers
)
server
.
Server
.
ReadTimeout
=
time
.
Duration
(
HttpServerTimeOut
)
*
time
.
Second
server
.
Server
.
WriteTimeout
=
time
.
Duration
(
HttpServerTimeOut
)
*
time
.
Second
server
.
Server
=
app
.
Server
if
ListenTCP4
&&
HttpAddr
==
""
{
server
.
Network
=
"tcp4"
}
...
...
grace/grace.go
View file @
d56491ab
...
...
@@ -99,7 +99,7 @@ func init() {
}
type
graceServer
struct
{
http
.
Server
*
http
.
Server
GraceListener
net
.
Listener
SignalHooks
map
[
int
]
map
[
os
.
Signal
][]
func
()
tlsInnerListener
*
graceListener
...
...
@@ -151,7 +151,7 @@ func NewServer(addr string, handler http.Handler) (srv *graceServer) {
state
:
STATE_INIT
,
Network
:
"tcp"
,
}
srv
.
Server
=
&
http
.
Server
{}
srv
.
Server
.
Addr
=
addr
srv
.
Server
.
ReadTimeout
=
DefaultReadTimeOut
srv
.
Server
.
WriteTimeout
=
DefaultWriteTimeOut
...
...
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