krz/skunky-art
Alternative privacy frontend for DeviantArt.
clone: git clone https://gitbay.org/krz/skunky-art.git
sonarcloud-cleanup: 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 = "Two API endpoints and template embedding into binary"
23
24 app.ExecuteCommandLineArguments()
25 app.ExecuteConfig()
26 static.CopyTemplatesToMemory()
27
28 // Rate/concurrency-limit + time-out outbound DeviantArt requests so bot floods
29 // can't exhaust the process or get our egress IP banned by CloudFront/WAF.
30 app.InstallDAThrottle()
31
32 // Only once the config is loaded and the throttle installed: this fetches over
33 // the network, so starting it earlier both raced ExecuteConfig's writes to CFG
34 // and let the request escape the throttle and the configured User-Agent.
35 go app.RefreshInstances()
36
37 go func() {
38 for {
39 err := devianter.UpdateCSRF()
40 if err != nil {
41 println(err.Error())
42 }
43 time.Sleep(12 * time.Hour)
44 }
45 }()
46
47 app.Router()
48}