-
Notifications
You must be signed in to change notification settings - Fork 11
/
server.go
60 lines (48 loc) · 1.38 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"net/http"
"github.com/gocraft/web"
// "github.com/gorilla/csrf"
// "github.com/NYTimes/gziphandler"
"github.com/jasonlvhit/gocron"
// "github.com/valyala/fasthttp"
// "github.com/valyala/fasthttp/fasthttpadaptor"
"qxklmrhx7qkzais6.onion/Tochka/tochka-free-market/modules/marketplace"
"qxklmrhx7qkzais6.onion/Tochka/tochka-free-market/modules/settings"
)
var (
APP_SETTINGS = settings.GetSettings()
)
func runCrons() {
if !APP_SETTINGS.Debug {
marketplace.StartTransactionsCron()
marketplace.StartWalletsCron()
marketplace.StartStatsCron()
marketplace.StartSERPCron()
marketplace.StartFrontPageCron()
marketplace.StartSupportTicketCron()
}
marketplace.StartCurrencyCron()
<-gocron.Start()
}
func runWebserver() {
// Root router
rootRouter := web.New(marketplace.Context{})
rootRouter.Middleware(web.StaticMiddleware("public"))
// Marketplace router
marketplace.ConfigureRouter(rootRouter.Subrouter(marketplace.Context{}, "/"))
// Start HTTP server
startHttpServer := func() {
address := fmt.Sprintf("%s:%s", APP_SETTINGS.Host, APP_SETTINGS.Port)
println(fmt.Sprintf("Running a HTTP server or, %s", address))
http.ListenAndServe(address, rootRouter)
// fasthttp.ListenAndServe(address, fasthttpadaptor.NewFastHTTPHandler(rootRouter))
}
// Start HTTPs server
startHttpServer()
}
func runServer() {
go runCrons()
runWebserver()
}