mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-09-15 17:46:55 +00:00
Those numbers are in kilobytes.
This commit is contained in:
parent
096fe787b7
commit
9b0597ca82
4 changed files with 16 additions and 16 deletions
|
@ -307,10 +307,10 @@ func httpError(statusCode int) error {
|
||||||
func GenerateKeys(outputFile, serverID, theirPublicStr string) {
|
func GenerateKeys(outputFile, serverID, theirPublicStr string) {
|
||||||
var err error
|
var err error
|
||||||
output := ConfigFile{
|
output := ConfigFile{
|
||||||
ListenAddr: "0.0.0.0:8001",
|
ListenAddr: "0.0.0.0:8001",
|
||||||
SocketOrigin: "localhost:8001",
|
SocketOrigin: "localhost:8001",
|
||||||
BackendURL: "http://localhost:8002/ffz",
|
BackendURL: "http://localhost:8002/ffz",
|
||||||
MinMemoryBytes: defaultMinMemory,
|
MinMemoryKBytes: defaultMinMemoryKB,
|
||||||
}
|
}
|
||||||
|
|
||||||
output.ServerID, err = strconv.Atoi(serverID)
|
output.ServerID, err = strconv.Atoi(serverID)
|
||||||
|
|
|
@ -35,7 +35,7 @@ const AuthorizeCommand Command = "do_authorize"
|
||||||
// on a goroutine over the ClientInfo.MessageChannel and should not be delivered immediately.
|
// on a goroutine over the ClientInfo.MessageChannel and should not be delivered immediately.
|
||||||
const AsyncResponseCommand Command = "_async"
|
const AsyncResponseCommand Command = "_async"
|
||||||
|
|
||||||
const defaultMinMemory = 1024 * 1024 * 24
|
const defaultMinMemoryKB = 1024 * 24
|
||||||
|
|
||||||
// TwitchDotTv is the http origin for twitch.tv.
|
// TwitchDotTv is the http origin for twitch.tv.
|
||||||
const TwitchDotTv = "http://www.twitch.tv"
|
const TwitchDotTv = "http://www.twitch.tv"
|
||||||
|
@ -52,8 +52,8 @@ var Configuration *ConfigFile
|
||||||
func SetupServerAndHandle(config *ConfigFile, serveMux *http.ServeMux) {
|
func SetupServerAndHandle(config *ConfigFile, serveMux *http.ServeMux) {
|
||||||
Configuration = config
|
Configuration = config
|
||||||
|
|
||||||
if config.MinMemoryBytes == 0 {
|
if config.MinMemoryKBytes == 0 {
|
||||||
config.MinMemoryBytes = defaultMinMemory
|
config.MinMemoryKBytes = defaultMinMemoryKB
|
||||||
}
|
}
|
||||||
|
|
||||||
setupBackend(config)
|
setupBackend(config)
|
||||||
|
@ -116,7 +116,7 @@ func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Header.Get("Connection") == "Upgrade" {
|
if r.Header.Get("Connection") == "Upgrade" {
|
||||||
updateSysMem()
|
updateSysMem()
|
||||||
|
|
||||||
if Statistics.SysMemTotal-Statistics.SysMemFree < Configuration.MinMemoryBytes {
|
if Statistics.SysMemTotalKB-Statistics.SysMemFreeKB < Configuration.MinMemoryKBytes {
|
||||||
w.WriteHeader(503)
|
w.WriteHeader(503)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
linuxproc "github.com/c9s/goprocinfo/linux"
|
linuxproc "github.com/c9s/goprocinfo/linux"
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StatsData struct {
|
type StatsData struct {
|
||||||
|
@ -25,10 +25,10 @@ type StatsData struct {
|
||||||
|
|
||||||
PubSubChannelCount int
|
PubSubChannelCount int
|
||||||
|
|
||||||
SysMemTotal uint64
|
SysMemTotalKB uint64
|
||||||
SysMemFree uint64
|
SysMemFreeKB uint64
|
||||||
MemoryInUse uint64
|
MemoryInUse uint64
|
||||||
MemoryRSS uint64
|
MemoryRSS uint64
|
||||||
|
|
||||||
MemoryPerClient uint64
|
MemoryPerClient uint64
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ func updateSysMem() {
|
||||||
sysMemLastUpdate = time.Now()
|
sysMemLastUpdate = time.Now()
|
||||||
memInfo, err := linuxproc.ReadMemInfo("/proc/meminfo")
|
memInfo, err := linuxproc.ReadMemInfo("/proc/meminfo")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
Statistics.SysMemTotal = memInfo.MemTotal
|
Statistics.SysMemTotalKB = memInfo.MemTotal
|
||||||
Statistics.SysMemFree = memInfo.MemAvailable
|
Statistics.SysMemFreeKB = memInfo.MemAvailable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ type ConfigFile struct {
|
||||||
BackendURL string
|
BackendURL string
|
||||||
|
|
||||||
// Minimum memory to accept a new connection
|
// Minimum memory to accept a new connection
|
||||||
MinMemoryBytes uint64
|
MinMemoryKBytes uint64
|
||||||
|
|
||||||
// SSL/TLS
|
// SSL/TLS
|
||||||
UseSSL bool
|
UseSSL bool
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue