break everything
- upgrade dependencies - run gofmt and goimports to organize code - fix typos - other small tweaks
This commit is contained in:
@@ -14,8 +14,9 @@ import (
|
||||
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/AlecAivazis/survey/v2/terminal"
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/pterodactyl/wings/config"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -21,11 +21,12 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/pkg/parsers/kernel"
|
||||
"github.com/docker/docker/pkg/parsers/operatingsystem"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"github.com/pterodactyl/wings/environment"
|
||||
"github.com/pterodactyl/wings/loggers/cli"
|
||||
"github.com/pterodactyl/wings/system"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const DefaultHastebinUrl = "https://ptero.co"
|
||||
|
||||
29
cmd/root.go
29
cmd/root.go
@@ -20,6 +20,10 @@ import (
|
||||
"github.com/gammazero/workerpool"
|
||||
"github.com/mitchellh/colorstring"
|
||||
"github.com/pkg/profile"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/crypto/acme"
|
||||
"golang.org/x/crypto/acme/autocert"
|
||||
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"github.com/pterodactyl/wings/environment"
|
||||
"github.com/pterodactyl/wings/loggers/cli"
|
||||
@@ -28,9 +32,6 @@ import (
|
||||
"github.com/pterodactyl/wings/server"
|
||||
"github.com/pterodactyl/wings/sftp"
|
||||
"github.com/pterodactyl/wings/system"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/crypto/acme"
|
||||
"golang.org/x/crypto/acme/autocert"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -40,7 +41,7 @@ var (
|
||||
|
||||
var rootCommand = &cobra.Command{
|
||||
Use: "wings",
|
||||
Short: "Runs the API server allowing programatic control of game servers for Pterodactyl Panel.",
|
||||
Short: "Runs the API server allowing programmatic control of game servers for Pterodactyl Panel.",
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
initConfig()
|
||||
initLogging()
|
||||
@@ -90,9 +91,9 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {
|
||||
case "mem":
|
||||
defer profile.Start(profile.MemProfile).Stop()
|
||||
case "alloc":
|
||||
defer profile.Start(profile.MemProfile, profile.MemProfileAllocs()).Stop()
|
||||
defer profile.Start(profile.MemProfile, profile.MemProfileAllocs).Stop()
|
||||
case "heap":
|
||||
defer profile.Start(profile.MemProfile, profile.MemProfileHeap()).Stop()
|
||||
defer profile.Start(profile.MemProfile, profile.MemProfileHeap).Stop()
|
||||
case "routines":
|
||||
defer profile.Start(profile.GoroutineProfile).Stop()
|
||||
case "mutex":
|
||||
@@ -159,7 +160,7 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {
|
||||
|
||||
// Just for some nice log output.
|
||||
for _, s := range manager.All() {
|
||||
log.WithField("server", s.Id()).Info("finished loading configuration for server")
|
||||
log.WithField("server", s.ID()).Info("finished loading configuration for server")
|
||||
}
|
||||
|
||||
states, err := manager.ReadStates()
|
||||
@@ -201,14 +202,14 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {
|
||||
pool.Submit(func() {
|
||||
s.Log().Info("configuring server environment and restoring to previous state")
|
||||
var st string
|
||||
if state, exists := states[s.Id()]; exists {
|
||||
if state, exists := states[s.ID()]; exists {
|
||||
st = state
|
||||
}
|
||||
|
||||
r, err := s.Environment.IsRunning()
|
||||
// We ignore missing containers because we don't want to actually block booting of wings at this
|
||||
// point. If we didn't do this and you pruned all of the images and then started wings you could
|
||||
// end up waiting a long period of time for all of the images to be re-pulled on Wings boot rather
|
||||
// point. If we didn't do this, and you pruned all the images and then started wings you could
|
||||
// end up waiting a long period of time for all the images to be re-pulled on Wings boot rather
|
||||
// than when the server itself is started.
|
||||
if err != nil && !client.IsErrNotFound(err) {
|
||||
s.Log().WithField("error", err).Error("error checking server environment status")
|
||||
@@ -246,10 +247,10 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {
|
||||
})
|
||||
}
|
||||
|
||||
// Wait until all of the servers are ready to go before we fire up the SFTP and HTTP servers.
|
||||
// Wait until all the servers are ready to go before we fire up the SFTP and HTTP servers.
|
||||
pool.StopWait()
|
||||
defer func() {
|
||||
// Cancel the context on all of the running servers at this point, even though the
|
||||
// Cancel the context on all the running servers at this point, even though the
|
||||
// program is just shutting down.
|
||||
for _, s := range manager.All() {
|
||||
s.CtxCancel()
|
||||
@@ -266,7 +267,7 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {
|
||||
|
||||
go func() {
|
||||
log.Info("updating server states on Panel: marking installing/restoring servers as normal")
|
||||
// Update all of the servers on the Panel to be in a valid state if they're
|
||||
// Update all the servers on the Panel to be in a valid state if they're
|
||||
// currently marked as installing/restoring now that Wings is restarted.
|
||||
if err := pclient.ResetServersState(cmd.Context()); err != nil {
|
||||
log.WithField("error", err).Error("failed to reset server states on Panel: some instances may be stuck in an installing/restoring state unexpectedly")
|
||||
@@ -348,7 +349,7 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {
|
||||
}
|
||||
|
||||
// Reads the configuration from the disk and then sets up the global singleton
|
||||
// with all of the configuration values.
|
||||
// with all the configuration values.
|
||||
func initConfig() {
|
||||
if !strings.HasPrefix(configPath, "/") {
|
||||
d, err := os.Getwd()
|
||||
|
||||
Reference in New Issue
Block a user