mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-03 16:38:31 +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) {
|
||||
var err error
|
||||
output := ConfigFile{
|
||||
ListenAddr: "0.0.0.0:8001",
|
||||
SocketOrigin: "localhost:8001",
|
||||
BackendURL: "http://localhost:8002/ffz",
|
||||
MinMemoryBytes: defaultMinMemory,
|
||||
ListenAddr: "0.0.0.0:8001",
|
||||
SocketOrigin: "localhost:8001",
|
||||
BackendURL: "http://localhost:8002/ffz",
|
||||
MinMemoryKBytes: defaultMinMemoryKB,
|
||||
}
|
||||
|
||||
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.
|
||||
const AsyncResponseCommand Command = "_async"
|
||||
|
||||
const defaultMinMemory = 1024 * 1024 * 24
|
||||
const defaultMinMemoryKB = 1024 * 24
|
||||
|
||||
// TwitchDotTv is the http origin for twitch.tv.
|
||||
const TwitchDotTv = "http://www.twitch.tv"
|
||||
|
@ -52,8 +52,8 @@ var Configuration *ConfigFile
|
|||
func SetupServerAndHandle(config *ConfigFile, serveMux *http.ServeMux) {
|
||||
Configuration = config
|
||||
|
||||
if config.MinMemoryBytes == 0 {
|
||||
config.MinMemoryBytes = defaultMinMemory
|
||||
if config.MinMemoryKBytes == 0 {
|
||||
config.MinMemoryKBytes = defaultMinMemoryKB
|
||||
}
|
||||
|
||||
setupBackend(config)
|
||||
|
@ -116,7 +116,7 @@ func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) {
|
|||
if r.Header.Get("Connection") == "Upgrade" {
|
||||
updateSysMem()
|
||||
|
||||
if Statistics.SysMemTotal-Statistics.SysMemFree < Configuration.MinMemoryBytes {
|
||||
if Statistics.SysMemTotalKB-Statistics.SysMemFreeKB < Configuration.MinMemoryKBytes {
|
||||
w.WriteHeader(503)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
linuxproc "github.com/c9s/goprocinfo/linux"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type StatsData struct {
|
||||
|
@ -25,10 +25,10 @@ type StatsData struct {
|
|||
|
||||
PubSubChannelCount int
|
||||
|
||||
SysMemTotal uint64
|
||||
SysMemFree uint64
|
||||
MemoryInUse uint64
|
||||
MemoryRSS uint64
|
||||
SysMemTotalKB uint64
|
||||
SysMemFreeKB uint64
|
||||
MemoryInUse uint64
|
||||
MemoryRSS uint64
|
||||
|
||||
MemoryPerClient uint64
|
||||
|
||||
|
@ -145,8 +145,8 @@ func updateSysMem() {
|
|||
sysMemLastUpdate = time.Now()
|
||||
memInfo, err := linuxproc.ReadMemInfo("/proc/meminfo")
|
||||
if err == nil {
|
||||
Statistics.SysMemTotal = memInfo.MemTotal
|
||||
Statistics.SysMemFree = memInfo.MemAvailable
|
||||
Statistics.SysMemTotalKB = memInfo.MemTotal
|
||||
Statistics.SysMemFreeKB = memInfo.MemAvailable
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ type ConfigFile struct {
|
|||
BackendURL string
|
||||
|
||||
// Minimum memory to accept a new connection
|
||||
MinMemoryBytes uint64
|
||||
MinMemoryKBytes uint64
|
||||
|
||||
// SSL/TLS
|
||||
UseSSL bool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue