Status update line, disabling web server

This commit is contained in:
farhan 2021-02-12 00:26:31 +00:00
parent 947645828e
commit cefacf7462
2 changed files with 36 additions and 5 deletions

View File

@ -8,6 +8,7 @@ import (
"regexp" "regexp"
"runtime" "runtime"
"sync" "sync"
"time"
) )
// Current instances // Current instances
@ -20,6 +21,37 @@ func startpprof() {
logFatal.Fatal(http.ListenAndServe("127.0.0.1:7777", nil)) logFatal.Fatal(http.ListenAndServe("127.0.0.1:7777", nil))
} }
func statusReport() {
for {
running := 0
keepalive := 0
unsupported := 0
mastodon := 0
pleroma := 0
other := 0
for _, o := range runninginstances {
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.Status == 200 {
other = other + 1
}
}
logInfo("Running:",running," Keepalive:", keepalive, " Unsupported:", unsupported, " M:", mastodon, ",P:",pleroma,",O:",other)
time.Sleep(time.Second*60)
}
}
func main() { func main() {
// Initial Setup // Initial Setup
logInit() logInit()
@ -50,7 +82,8 @@ func main() {
} }
go startctl() go startctl()
go webmain() //go webmain()
go statusReport()
runtime.Goexit() runtime.Goexit()
} }

View File

@ -192,10 +192,6 @@ func StartInstance(endpoint string) {
o = GetNodeInfo(endpoint, o) o = GetNodeInfo(endpoint, o)
UpdateRunner(endpoint, o) UpdateRunner(endpoint, o)
if o.Software == "" {
return
}
if o.Software == "pleroma" { if o.Software == "pleroma" {
logConn("Starting " + endpoint + " as " + o.Software + " " + o.Version) logConn("Starting " + endpoint + " as " + o.Software + " " + o.Version)
o.CaptureType = "Poll" o.CaptureType = "Poll"
@ -207,6 +203,8 @@ func StartInstance(endpoint string) {
UpdateRunner(endpoint, o) UpdateRunner(endpoint, o)
StreamMastodon(endpoint, &o) StreamMastodon(endpoint, &o)
} else { } else {
o.Status = 605
UpdateRunner(endpoint, o)
logConn("Unsupported endpoint " + endpoint) logConn("Unsupported endpoint " + endpoint)
} }
} }