fedilogue/fedilogue.go

54 lines
1.0 KiB
Go
Raw Normal View History

package main
import (
2020-12-29 20:20:02 +00:00
"github.com/jackc/pgx/pgxpool"
2020-12-17 04:23:25 +00:00
"github.com/microcosm-cc/bluemonday"
"net/http"
2020-12-17 04:23:25 +00:00
_ "net/http/pprof"
2020-12-06 18:05:17 -05:00
"regexp"
"runtime"
2020-12-17 04:23:25 +00:00
"sync"
)
// Current instances
var runninginstances map[string]RunningInstance
var ri_mutex = &sync.Mutex{}
2020-12-18 06:06:32 +00:00
var pool *pgxpool.Pool
2020-11-24 20:36:47 -05:00
func startpprof() {
logInfo.Print("Starting http/pprof on :7777")
logFatal.Fatal(http.ListenAndServe("127.0.0.1:7777", nil))
2020-11-24 20:36:47 -05:00
}
2020-11-24 20:36:47 -05:00
func main() {
// Initial Setup
logInit()
2020-11-24 20:36:47 -05:00
runninginstances = make(map[string]RunningInstance)
getSettings()
2020-11-24 20:36:47 -05:00
go startpprof()
2020-11-16 00:10:33 -05:00
2020-12-18 06:06:32 +00:00
pool = getDbPool()
2020-12-06 18:05:17 -05:00
p = bluemonday.NewPolicy()
spaceReg = regexp.MustCompile(`[\s\t\.]+`)
2021-01-14 20:43:20 +00:00
removeHTMLReg = regexp.MustCompile(`<\/?\s*br\s*>`)
re = regexp.MustCompile("^https?://([^/]*)/(.*)$")
for _, endpoint := range settings.Autostart {
logInfo.Print("Autostarting " + endpoint)
ri_mutex.Lock()
_, exists := runninginstances[endpoint]
if exists == false {
runninginstances[endpoint] = RunningInstance{}
go StartInstance(endpoint)
}
ri_mutex.Unlock()
}
go startctl()
go webmain()
runtime.Goexit()
}