krz/skunky-art
clone: git clone https://gitbay.org/krz/skunky-art.git
main: main.go · raw
1package main
2
3import (
4 "skunkyart/app"
5 "skunkyart/static"
6 "time"
7
8 "github.com/krazywarez/devianter"
9)
10
11// version is the release this binary was built from. The release workflow links
12// it in from the git tag so that --help and /api/instance cannot drift from the
13// tag the image was built at:
14//
15// go build -ldflags "-X main.version=1.3.7"
16//
17// A plain `go build` leaves it as "dev".
18var version = "dev"
19
20func main() {
21 app.Release.Version = version
22 app.Release.Description = "Themes, a JSON API for search and deviations, and a multilingual interface"
23
24 app.ExecuteCommandLineArguments()
25 app.ExecuteConfig()
26 static.CopyTemplatesToMemory()
27
28 // After the copy, not before: the catalogues are assets, and ExecuteConfig
29 // runs while static/ is still unread.
30 app.LoadLanguages()
31
32 // Rate/concurrency-limit + time-out outbound DeviantArt requests so bot floods
33 // can't exhaust the process or get our egress IP banned by CloudFront/WAF.
34 app.InstallDAThrottle()
35
36 // Only once the config is loaded and the throttle installed: this fetches over
37 // the network, so starting it earlier both raced ExecuteConfig's writes to CFG
38 // and let the request escape the throttle and the configured User-Agent.
39 go app.RefreshInstances()
40
41 go func() {
42 for {
43 err := devianter.UpdateCSRF()
44 if err != nil {
45 println(err.Error())
46 }
47 time.Sleep(12 * time.Hour)
48 }
49 }()
50
51 app.Router()
52}