From 3e9fbc1910015cf7782d33929506aaa609f02f7f Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Sun, 16 Jul 2023 05:32:05 +0000 Subject: [PATCH] Removing renamed file --- fedilogger/fedilogue.go | 123 ---------------------------------------- 1 file changed, 123 deletions(-) delete mode 100644 fedilogger/fedilogue.go diff --git a/fedilogger/fedilogue.go b/fedilogger/fedilogue.go deleted file mode 100644 index 816cd44..0000000 --- a/fedilogger/fedilogue.go +++ /dev/null @@ -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() -}