config: add ability to enable/disable server crash detection
fixes https://github.com/pterodactyl/panel/issues/3617 Co-authored-by: Alex <admin@softwarenoob.com>
This commit is contained in:
@@ -48,10 +48,12 @@ var DefaultTLSConfig = &tls.Config{
|
||||
CurvePreferences: []tls.CurveID{tls.X25519, tls.CurveP256},
|
||||
}
|
||||
|
||||
var mu sync.RWMutex
|
||||
var _config *Configuration
|
||||
var _jwtAlgo *jwt.HMACSHA
|
||||
var _debugViaFlag bool
|
||||
var (
|
||||
mu sync.RWMutex
|
||||
_config *Configuration
|
||||
_jwtAlgo *jwt.HMACSHA
|
||||
_debugViaFlag bool
|
||||
)
|
||||
|
||||
// Locker specific to writing the configuration to the disk, this happens
|
||||
// in areas that might already be locked, so we don't want to crash the process.
|
||||
@@ -181,6 +183,9 @@ type SystemConfiguration struct {
|
||||
}
|
||||
|
||||
type CrashDetection struct {
|
||||
// CrashDetectionEnabled sets if crash detection is enabled globally for all servers on this node.
|
||||
CrashDetectionEnabled bool `default:"true" yaml:"enabled"`
|
||||
|
||||
// Determines if Wings should detect a server that stops with a normal exit code of
|
||||
// "0" as being crashed if the process stopped without any Wings interaction. E.g.
|
||||
// the user did not press the stop button, but the process stopped cleanly.
|
||||
@@ -375,7 +380,7 @@ func WriteToDisk(c *Configuration) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(c.path, b, 0600); err != nil {
|
||||
if err := ioutil.WriteFile(c.path, b, 0o600); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -470,7 +475,7 @@ func FromFile(path string) error {
|
||||
func ConfigureDirectories() error {
|
||||
root := _config.System.RootDirectory
|
||||
log.WithField("path", root).Debug("ensuring root data directory exists")
|
||||
if err := os.MkdirAll(root, 0700); err != nil {
|
||||
if err := os.MkdirAll(root, 0o700); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -491,17 +496,17 @@ func ConfigureDirectories() error {
|
||||
}
|
||||
|
||||
log.WithField("path", _config.System.Data).Debug("ensuring server data directory exists")
|
||||
if err := os.MkdirAll(_config.System.Data, 0700); err != nil {
|
||||
if err := os.MkdirAll(_config.System.Data, 0o700); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.WithField("path", _config.System.ArchiveDirectory).Debug("ensuring archive data directory exists")
|
||||
if err := os.MkdirAll(_config.System.ArchiveDirectory, 0700); err != nil {
|
||||
if err := os.MkdirAll(_config.System.ArchiveDirectory, 0o700); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.WithField("path", _config.System.BackupDirectory).Debug("ensuring backup data directory exists")
|
||||
if err := os.MkdirAll(_config.System.BackupDirectory, 0700); err != nil {
|
||||
if err := os.MkdirAll(_config.System.BackupDirectory, 0o700); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user