MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / Start

Function Start

core/server/server.go:37–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35)
36
37func Start() {
38 re.Init()
39 viper.Init()
40 log.Init()
41 db.Init()
42 migration.Init()
43 i18n.Init()
44 validator.Init()
45 geo.Init()
46 gob.Register(psession.SessionUser{})
47 cron.Init()
48 session.Init()
49 hook.Init()
50 InitOthers()
51
52 proxy.Init()
53
54 rootRouter := router.Routers()
55
56 if global.CONF.Base.Mode != "stable" {
57 gin.SetMode(gin.DebugMode)
58 } else {
59 gin.SetMode(gin.ReleaseMode)
60 }
61
62 global.IPTracker = auth.NewIPTracker()
63
64 tcpItem := "tcp4"
65 if global.CONF.Conn.Ipv6 == constant.StatusEnable {
66 tcpItem = "tcp"
67 global.CONF.Conn.BindAddress = fmt.Sprintf("[%s]", global.CONF.Conn.BindAddress)
68 }
69 server := &http.Server{
70 Addr: global.CONF.Conn.BindAddress + ":" + global.CONF.Conn.Port,
71 Handler: rootRouter,
72 ReadHeaderTimeout: 5 * time.Second,
73 ReadTimeout: 600 * time.Second,
74 WriteTimeout: 600 * time.Second,
75 IdleTimeout: 240 * time.Second,
76 }
77 ln, err := net.Listen(tcpItem, server.Addr)
78 if err != nil {
79 panic(err)
80 }
81 type tcpKeepAliveListener struct {
82 *net.TCPListener
83 }
84 switch global.CONF.Conn.SSL {
85 case constant.StatusEnable:
86 constant.CertStore.Store(loadCert())
87
88 server.TLSConfig = &tls.Config{
89 GetCertificate: func(info *tls.ClientHelloInfo) (*tls.Certificate, error) {
90 return constant.CertStore.Load().(*tls.Certificate), nil
91 },
92 }
93 global.LOG.Infof("listen at https://%s:%s [%s]", global.CONF.Conn.BindAddress, global.CONF.Conn.Port, tcpItem)
94

Callers

nothing calls this directly

Calls 4

loadCertFunction · 0.85
handleMuxHttpConnFunction · 0.85
InitOthersFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected