Cleanup data storage locations for daemon
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"go.uber.org/zap"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -11,8 +12,6 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
const stateFileLocation = "data/.states.json"
|
||||
|
||||
var stateMutex sync.Mutex
|
||||
|
||||
// Returns the state of the servers.
|
||||
@@ -22,7 +21,7 @@ func getServerStates() (map[string]string, error) {
|
||||
defer stateMutex.Unlock()
|
||||
|
||||
// Open the states file.
|
||||
f, err := os.OpenFile(stateFileLocation, os.O_RDONLY|os.O_CREATE, 0644)
|
||||
f, err := os.OpenFile(config.Get().System.GetStatesPath(), os.O_RDONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
@@ -55,7 +54,7 @@ func saveServerStates() error {
|
||||
defer stateMutex.Unlock()
|
||||
|
||||
// Write the data to the file
|
||||
if err := ioutil.WriteFile(stateFileLocation, data, 0644); err != nil {
|
||||
if err := ioutil.WriteFile(config.Get().System.GetStatesPath(), data, 0644); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
@@ -141,4 +140,4 @@ func (s *Server) GetState() string {
|
||||
// not the response from Docker.
|
||||
func (s *Server) IsRunning() bool {
|
||||
return s.GetState() == ProcessRunningState || s.GetState() == ProcessStartingState
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user