Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-pai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
szh
chain33-pai
Commits
377c43f7
Commit
377c43f7
authored
Jan 10, 2020
by
ligaishun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加main入口
parent
8cff0dd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
main.go
main.go
+61
-0
No files found.
main.go
0 → 100644
View file @
377c43f7
package
main
import
(
"chain33-pai/models"
"chain33-pai/pkg/app"
"chain33-pai/pkg/setting"
"chain33-pai/pkg/util"
"chain33-pai/routers"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"time"
)
func
init
()
{
setting
.
Setup
()
models
.
Setup
()
//logging.Setup()
//gredis.Setup()
util
.
Setup
()
}
// @title Golang Gin API
// @version 1.0
// @description An example of gin
// @termsOfService https://chain33-pai
// @license.name MIT
// @license.url https://chain33-pai/blob/master/LICENSE
func
main
()
{
go
app
.
CornClean
(
time
.
NewTicker
(
time
.
Hour
*
24
))
gin
.
SetMode
(
setting
.
ServerSetting
.
RunMode
)
routersInit
:=
routers
.
InitRouter
()
readTimeout
:=
setting
.
ServerSetting
.
ReadTimeout
writeTimeout
:=
setting
.
ServerSetting
.
WriteTimeout
endPoint
:=
fmt
.
Sprintf
(
":%d"
,
setting
.
ServerSetting
.
HttpPort
)
maxHeaderBytes
:=
1
<<
20
server
:=
&
http
.
Server
{
Addr
:
endPoint
,
Handler
:
routersInit
,
ReadTimeout
:
readTimeout
,
WriteTimeout
:
writeTimeout
,
MaxHeaderBytes
:
maxHeaderBytes
,
}
server
.
ListenAndServe
()
select
{}
// If you want Graceful Restart, you need a Unix system and download github.com/fvbock/endless
//endless.DefaultReadTimeOut = readTimeout
//endless.DefaultWriteTimeOut = writeTimeout
//endless.DefaultMaxHeaderBytes = maxHeaderBytes
//server := endless.NewServer(endPoint, routersInit)
//server.BeforeBegin = func(add string) {
// log.Printf("Actual pid is %d", syscall.Getpid())
//}
//
//err := server.ListenAndServe()
//if err != nil {
// log.Printf("Server err: %v", err)
//}
}
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