Generate a nicer install log with more detailed information

This commit is contained in:
Dane Everitt 2020-06-30 20:45:36 -07:00
parent d6a3d9adb1
commit 79a582a5f2
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -13,6 +13,7 @@ import (
"github.com/pterodactyl/wings/api" "github.com/pterodactyl/wings/api"
"github.com/pterodactyl/wings/config" "github.com/pterodactyl/wings/config"
"golang.org/x/sync/semaphore" "golang.org/x/sync/semaphore"
"html/template"
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
@ -349,7 +350,37 @@ func (ip *InstallationProcess) AfterExecute(containerId string) error {
defer f.Close() defer f.Close()
// We write the contents of the container output to a more "permanent" file so that they // 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 { if _, err := io.Copy(f, reader); err != nil {
return errors.WithStack(err) return errors.WithStack(err)
} }