From 79a582a5f274046350ce0280d7f429cf0e02f58c Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 30 Jun 2020 20:45:36 -0700 Subject: [PATCH] Generate a nicer install log with more detailed information --- server/install.go | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/server/install.go b/server/install.go index e5e8ad9..99faadd 100644 --- a/server/install.go +++ b/server/install.go @@ -13,6 +13,7 @@ import ( "github.com/pterodactyl/wings/api" "github.com/pterodactyl/wings/config" "golang.org/x/sync/semaphore" + "html/template" "io" "io/ioutil" "os" @@ -349,7 +350,37 @@ func (ip *InstallationProcess) AfterExecute(containerId string) error { defer f.Close() // We write the contents of the container output to a more "permanent" file so that they - // can be referenced after this container is deleted. + // can be referenced after this container is deleted. We'll also include the environment + // variables passed into the container to make debugging things a little easier. + ip.Server.Log().WithField("path", ip.GetLogPath()).Debug("writing most recent installation logs to disk") + + tmpl, err := template.New("header").Parse(`Pterodactyl Server Installation Log + +| +| Details +| ------------------------------ + Server UUID: {{.Server.Uuid}} + Container Image: {{.Script.ContainerImage}} + Container Entrypoint: {{.Script.Entrypoint}} + +| +| Environment Variables +| ------------------------------ +{{ range $key, $value := .Server.GetEnvironmentVariables }} {{ $value }} +{{ end }} + +| +| Script Output +| ------------------------------ +`) + if err != nil { + return errors.WithStack(err) + } + + if err := tmpl.Execute(f, ip); err != nil { + return errors.WithStack(err) + } + if _, err := io.Copy(f, reader); err != nil { return errors.WithStack(err) }