GameStats,ServerBrowser: Fix invalid state path

This commit is contained in:
mkwcat 2024-05-07 21:19:16 -04:00
parent 268f415e97
commit 74e5c6a910
No known key found for this signature in database
GPG Key ID: 7A505679CE9E7AA9
2 changed files with 14 additions and 4 deletions

View File

@ -70,7 +70,7 @@ func StartServer(reload bool) {
if reload {
// Load state
file, err := os.Open("/state/gstats_sessions.gob")
file, err := os.Open("state/gstats_sessions.gob")
if err != nil {
panic(err)
}
@ -93,12 +93,14 @@ func StartServer(reload bool) {
delete(sessionsByConnIndex, session.ConnIndex)
}
}
logging.Notice("GSTATS", "Loaded", aurora.Cyan(len(sessionsByConnIndex)), "sessions")
}
}
func Shutdown() {
// Save state
file, err := os.OpenFile("/state/gstats_sessions.gob", os.O_CREATE|os.O_WRONLY, 0644)
file, err := os.OpenFile("state/gstats_sessions.gob", os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic(err)
}
@ -111,6 +113,10 @@ func Shutdown() {
if err != nil {
panic(err)
}
pool.Close()
logging.Notice("GSTATS", "Saved", aurora.Cyan(len(sessionsByConnIndex)), "sessions")
}
func NewConnection(index uint64, address string) {

View File

@ -42,7 +42,7 @@ func StartServer(reload bool) {
}
// Load connection state
file, err := os.Open("/state/sb_connections.gob")
file, err := os.Open("state/sb_connections.gob")
if err != nil {
panic(err)
}
@ -55,11 +55,13 @@ func StartServer(reload bool) {
if err != nil {
panic(err)
}
logging.Notice("SB", "Loaded", aurora.Cyan(len(connBuffers)), "connections")
}
func Shutdown() {
// Save connection state
file, err := os.OpenFile("/state/sb_connections.gob", os.O_CREATE|os.O_WRONLY, 0644)
file, err := os.OpenFile("state/sb_connections.gob", os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic(err)
}
@ -71,6 +73,8 @@ func Shutdown() {
if err != nil {
panic(err)
}
logging.Notice("SB", "Saved", aurora.Cyan(len(connBuffers)), "connections")
}
func NewConnection(index uint64, address string) {