mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-09-15 17:46:55 +00:00
Post to backend when server start
This commit is contained in:
parent
95a8f710f8
commit
a4bac68d02
3 changed files with 19 additions and 2 deletions
|
@ -48,12 +48,13 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Could not create logfile: ", err)
|
log.Fatal("Could not create logfile: ", err)
|
||||||
}
|
}
|
||||||
log.SetOutput(logFile)
|
|
||||||
|
|
||||||
server.SetupServerAndHandle(conf, nil)
|
server.SetupServerAndHandle(conf, nil)
|
||||||
|
|
||||||
go commandLineConsole()
|
go commandLineConsole()
|
||||||
|
|
||||||
|
log.SetOutput(logFile)
|
||||||
|
|
||||||
if conf.UseSSL {
|
if conf.UseSSL {
|
||||||
err = httpServer.ListenAndServeTLS(conf.SSLCertificateFile, conf.SSLKeyFile)
|
err = httpServer.ListenAndServeTLS(conf.SSLCertificateFile, conf.SSLKeyFile)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,6 +26,7 @@ var responseCache *cache.Cache
|
||||||
var getBacklogUrl string
|
var getBacklogUrl string
|
||||||
var postStatisticsUrl string
|
var postStatisticsUrl string
|
||||||
var addTopicUrl string
|
var addTopicUrl string
|
||||||
|
var announceStartupUrl string
|
||||||
|
|
||||||
var backendSharedKey [32]byte
|
var backendSharedKey [32]byte
|
||||||
var serverId int
|
var serverId int
|
||||||
|
@ -43,6 +44,7 @@ func SetupBackend(config *ConfigFile) {
|
||||||
getBacklogUrl = fmt.Sprintf("%s/backlog", backendUrl)
|
getBacklogUrl = fmt.Sprintf("%s/backlog", backendUrl)
|
||||||
postStatisticsUrl = fmt.Sprintf("%s/stats", backendUrl)
|
postStatisticsUrl = fmt.Sprintf("%s/stats", backendUrl)
|
||||||
addTopicUrl = fmt.Sprintf("%s/topics", backendUrl)
|
addTopicUrl = fmt.Sprintf("%s/topics", backendUrl)
|
||||||
|
announceStartupUrl = fmt.Sprintf("%s/startup", backendUrl)
|
||||||
|
|
||||||
messageBufferPool.New = New4KByteBuffer
|
messageBufferPool.New = New4KByteBuffer
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -92,7 +93,7 @@ func SetupServerAndHandle(config *ConfigFile, serveMux *http.ServeMux) {
|
||||||
|
|
||||||
bannerBytes, err := ioutil.ReadFile("index.html")
|
bannerBytes, err := ioutil.ReadFile("index.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Could not open index.html", err)
|
log.Fatalln("Could not open index.html:", err)
|
||||||
}
|
}
|
||||||
BannerHTML = bannerBytes
|
BannerHTML = bannerBytes
|
||||||
|
|
||||||
|
@ -101,6 +102,19 @@ func SetupServerAndHandle(config *ConfigFile, serveMux *http.ServeMux) {
|
||||||
serveMux.HandleFunc("/dump_backlog", HBackendDumpBacklog)
|
serveMux.HandleFunc("/dump_backlog", HBackendDumpBacklog)
|
||||||
serveMux.HandleFunc("/update_and_pub", HBackendUpdateAndPublish)
|
serveMux.HandleFunc("/update_and_pub", HBackendUpdateAndPublish)
|
||||||
|
|
||||||
|
announceForm, err := SealRequest(url.Values{
|
||||||
|
"startup": []string{"1"},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln("Unable to seal requests:", err)
|
||||||
|
}
|
||||||
|
resp, err := backendHttpClient.PostForm(announceStartupUrl, announceForm)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
} else {
|
||||||
|
resp.Body.Close()
|
||||||
|
}
|
||||||
|
|
||||||
go pubsubJanitor()
|
go pubsubJanitor()
|
||||||
go backlogJanitor()
|
go backlogJanitor()
|
||||||
go authorizationJanitor()
|
go authorizationJanitor()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue