Skip to content

Commit

Permalink
chore: avoid exiting if config file is not writable
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Penner <[email protected]>
  • Loading branch information
matthewpi committed Mar 10, 2025
1 parent 49b04fe commit f18726c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"path/filepath"
"runtime"
"strconv"
"syscall"
"time"

"github.com/NYTimes/logrotate"
Expand Down Expand Up @@ -103,6 +104,7 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {

if err := config.ConfigureTimezone(); err != nil {
log.WithField("error", err).Fatal("failed to detect system timezone or use supplied configuration value")
return
}
log.WithField("timezone", config.Get().System.Timezone).Info("configured wings with system timezone")
if err := config.ConfigureDirectories(); err != nil {
Expand All @@ -111,9 +113,11 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {
}
if err := config.EnsurePterodactylUser(); err != nil {
log.WithField("error", err).Fatal("failed to create pterodactyl system user")
return
}
if err := config.ConfigurePasswd(); err != nil {
log.WithField("error", err).Fatal("failed to configure container passwd file")
return
}
log.WithFields(log.Fields{
"username": config.Get().System.Username,
Expand All @@ -136,19 +140,26 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {

if err := database.Initialize(); err != nil {
log.WithField("error", err).Fatal("failed to initialize database")
return
}

manager, err := server.NewManager(cmd.Context(), pclient)
if err != nil {
log.WithField("error", err).Fatal("failed to load server configurations")
return
}

if err := environment.ConfigureDocker(cmd.Context()); err != nil {
log.WithField("error", err).Fatal("failed to configure docker environment")
return
}

if err := config.WriteToDisk(config.Get()); err != nil {
log.WithField("error", err).Fatal("failed to write configuration to disk")
if !errors.Is(err, syscall.EROFS) {
log.WithField("error", err).Error("failed to write configuration to disk")
} else {
log.WithField("error", err).Debug("failed to write configuration to disk")
}
}

// Just for some nice log output.
Expand Down

0 comments on commit f18726c

Please sign in to comment.