Removing renamed file
This commit is contained in:
parent
546244a959
commit
3e9fbc1910
@ -1,123 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/microcosm-cc/bluemonday"
|
||||
"gitlab.com/khanzf/fedilogue/shared"
|
||||
)
|
||||
|
||||
// Current instances
|
||||
var runninginstances map[string]shared.RunningInstance
|
||||
var ri_mutex = &sync.Mutex{}
|
||||
|
||||
func startpprof() {
|
||||
logInfo("Starting http/pprof on :7777")
|
||||
logFatal(http.ListenAndServe("127.0.0.1:7777", nil))
|
||||
}
|
||||
|
||||
func statusReportHandler() {
|
||||
for {
|
||||
StatusReport()
|
||||
time.Sleep(time.Second * 60)
|
||||
}
|
||||
}
|
||||
|
||||
/* Tests:
|
||||
- TestStatusReport_empty_run
|
||||
- TestStatusReport_full_content
|
||||
*/
|
||||
func StatusReport() {
|
||||
running := 0
|
||||
keepalive := 0
|
||||
unsupported := 0
|
||||
|
||||
mastodon := 0
|
||||
pleroma := 0
|
||||
misskey := 0
|
||||
other := 0
|
||||
ri_mutex.Lock()
|
||||
for i, o := range runninginstances {
|
||||
logDebug("Software ", o.Software, " Status: ", o.Status, " instance ", i)
|
||||
if o.Status == 200 {
|
||||
running = running + 1
|
||||
} else if o.Status == 607 { // Keepalive
|
||||
keepalive = keepalive + 1
|
||||
} else if o.Status == 605 { // Unsupported instance
|
||||
unsupported = unsupported + 1
|
||||
}
|
||||
|
||||
if o.Software == "mastodon" && o.Status == 200 {
|
||||
mastodon = mastodon + 1
|
||||
} else if o.Software == "pleroma" && o.Status == 200 {
|
||||
pleroma = pleroma + 1
|
||||
} else if o.Software == "misskey" && o.Status == 200 {
|
||||
misskey = misskey + 1
|
||||
} else if o.Status == 200 {
|
||||
other = other + 1
|
||||
}
|
||||
}
|
||||
ri_mutex.Unlock()
|
||||
logInfo("Running:", running, " Keepalive:", keepalive, " Unsupported:", unsupported, " Ma:", mastodon, ",P:", pleroma, ",Mi:", misskey, ",O:", other)
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Initial Setup
|
||||
logInit()
|
||||
runninginstances = make(map[string]shared.RunningInstance)
|
||||
|
||||
getSettings()
|
||||
if len(settings.Proxies) > 0 {
|
||||
for i := 0; i < len(settings.Proxies); i++ {
|
||||
logInfo("Using proxy: ", settings.Proxies[i].Host, ":", settings.Proxies[i].Port)
|
||||
}
|
||||
}
|
||||
go startpprof()
|
||||
|
||||
pool = getDbPool()
|
||||
|
||||
p = bluemonday.NewPolicy()
|
||||
spaceReg = regexp.MustCompile(`[\s\t\.]+`)
|
||||
removeHTMLReg = regexp.MustCompile(`<\/?\s*br\s*>`)
|
||||
re = regexp.MustCompile("^https?://([^/]*)/(.*)$")
|
||||
matchurl = regexp.MustCompile("http?s://[\\w\\-]+\\.[\\w\\-]+\\S*")
|
||||
staggeredStartChan = make(chan bool)
|
||||
|
||||
// Start instances located in database
|
||||
rows, err := pool.Query(context.Background(), "SELECT endpoint FROM instances")
|
||||
if err != nil {
|
||||
logErr("Unable to select from instances")
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
go staggeredStart()
|
||||
go statusReportHandler()
|
||||
|
||||
for rows.Next() {
|
||||
var endpoint string
|
||||
err = rows.Scan(&endpoint)
|
||||
if err != nil {
|
||||
logErr("Unable to iterate database, exiting.")
|
||||
return
|
||||
}
|
||||
o, exists := GetRunner(endpoint)
|
||||
if o.Banned == true {
|
||||
continue // Banned instance
|
||||
}
|
||||
if exists == false {
|
||||
go StartInstance(endpoint)
|
||||
}
|
||||
}
|
||||
|
||||
go startctl()
|
||||
go webmain()
|
||||
|
||||
runtime.Goexit()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user