fedilogue/fedilogue.go
Farhan Khan 1adaba8322 retrying connections + logging prefix
this is because some hosting providers throttle rapid new connections
regex additions
2021-01-14 19:51:42 +00:00

53 lines
1017 B
Go

package main
import (
"github.com/jackc/pgx/pgxpool"
"github.com/microcosm-cc/bluemonday"
"net/http"
_ "net/http/pprof"
"regexp"
"runtime"
"sync"
)
// Current instances
var runninginstances map[string]RunningInstance
var ri_mutex = &sync.Mutex{}
var pool *pgxpool.Pool
func startpprof() {
logInfo.Print("Starting http/pprof on :7777")
logFatal.Fatal(http.ListenAndServe("127.0.0.1:7777", nil))
}
func main() {
// Initial Setup
logInit()
runninginstances = make(map[string]RunningInstance)
getSettings()
go startpprof()
pool = getDbPool()
p = bluemonday.NewPolicy()
spaceReg = regexp.MustCompile(`[\s\t\.]+`)
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()
}