2020-11-10 21:53:46 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
_ "net/http/pprof"
|
|
|
|
"net/http"
|
2020-11-17 18:28:59 -05:00
|
|
|
"sync"
|
2020-11-10 21:53:46 -05:00
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
2020-11-17 18:28:59 -05:00
|
|
|
// Current instances
|
|
|
|
var runninginstances map[string]RunningInstance
|
|
|
|
var ri_mutex = &sync.Mutex{}
|
2020-11-10 21:53:46 -05:00
|
|
|
|
2020-11-24 20:36:47 -05:00
|
|
|
func startpprof() {
|
|
|
|
log.Print("Starting http/pprof on :7777")
|
|
|
|
log.Fatal(http.ListenAndServe("127.0.0.1:7777", nil))
|
|
|
|
}
|
2020-11-10 21:53:46 -05:00
|
|
|
|
2020-11-24 20:36:47 -05:00
|
|
|
func main() {
|
2020-11-10 21:53:46 -05:00
|
|
|
// Initial Setup
|
2020-11-16 00:10:33 -05:00
|
|
|
reportPostChan := make(chan ReportPost)
|
2020-11-24 20:36:47 -05:00
|
|
|
runninginstances = make(map[string]RunningInstance)
|
2020-11-10 21:53:46 -05:00
|
|
|
|
2020-11-24 20:36:47 -05:00
|
|
|
go startpprof()
|
2020-11-16 00:10:33 -05:00
|
|
|
|
2020-11-24 20:36:47 -05:00
|
|
|
pool := get_db_pool()
|
|
|
|
go startctl(reportPostChan)
|
|
|
|
go webmain(reportPostChan)
|
|
|
|
for { // Write posts
|
|
|
|
v := <-reportPostChan
|
2020-11-17 22:35:59 -05:00
|
|
|
go writePost(pool, v)
|
2020-11-10 21:53:46 -05:00
|
|
|
}
|
|
|
|
}
|