Better approach to timezone handling by using a TZ environment variable
This commit is contained in:
parent
06f495682c
commit
d7bd10fcee
|
@ -166,7 +166,7 @@ type DockerConfiguration struct {
|
||||||
|
|
||||||
// Defines the location of the timezone file on the host system that should
|
// Defines the location of the timezone file on the host system that should
|
||||||
// be mounted into the created containers so that they all use the same time.
|
// be mounted into the created containers so that they all use the same time.
|
||||||
TimezonePath string `default:"/etc/localtime" yaml:"timezone_path"`
|
TimezonePath string `default:"/etc/timezone" yaml:"timezone_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defines the configuration for the internal API that is exposed by the
|
// Defines the configuration for the internal API that is exposed by the
|
||||||
|
|
|
@ -246,8 +246,6 @@ func (d *DockerEnvironment) Start() error {
|
||||||
// No errors, good to continue through.
|
// No errors, good to continue through.
|
||||||
sawError = false
|
sawError = false
|
||||||
|
|
||||||
zap.S().Debugw("right before start attach")
|
|
||||||
|
|
||||||
return d.Attach()
|
return d.Attach()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,13 +596,16 @@ func (d *DockerEnvironment) Create() error {
|
||||||
NetworkMode: "pterodactyl_nw",
|
NetworkMode: "pterodactyl_nw",
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mountTimezoneData(hostConf); err != nil {
|
// Pretty sure TZ=X in the environment variables negates the need for this
|
||||||
if os.IsNotExist(err) {
|
// to happen. Leaving it until I can confirm that works for everything.
|
||||||
zap.S().Warnw("the timezone data path configured does not exist on the system", zap.Error(errors.WithStack(err)))
|
//
|
||||||
} else {
|
// if err := mountTimezoneData(hostConf); err != nil {
|
||||||
zap.S().Warnw("failed to mount timezone data into container", zap.Error(errors.WithStack(err)))
|
// if os.IsNotExist(err) {
|
||||||
}
|
// zap.S().Warnw("the timezone data path configured does not exist on the system", zap.Error(errors.WithStack(err)))
|
||||||
}
|
// } else {
|
||||||
|
// zap.S().Warnw("failed to mount timezone data into container", zap.Error(errors.WithStack(err)))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if _, err := cli.ContainerCreate(ctx, conf, hostConf, nil, d.Server.Uuid); err != nil {
|
if _, err := cli.ContainerCreate(ctx, conf, hostConf, nil, d.Server.Uuid); err != nil {
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
|
@ -728,7 +729,10 @@ func (d *DockerEnvironment) parseLogToStrings(b []byte) ([]string, error) {
|
||||||
|
|
||||||
// Returns the environment variables for a server in KEY="VALUE" form.
|
// Returns the environment variables for a server in KEY="VALUE" form.
|
||||||
func (d *DockerEnvironment) environmentVariables() []string {
|
func (d *DockerEnvironment) environmentVariables() []string {
|
||||||
|
zone, _ := time.Now().In(time.Local).Zone()
|
||||||
|
|
||||||
var out = []string{
|
var out = []string{
|
||||||
|
fmt.Sprintf("TZ=%s", zone),
|
||||||
fmt.Sprintf("STARTUP=%s", d.Server.Invocation),
|
fmt.Sprintf("STARTUP=%s", d.Server.Invocation),
|
||||||
fmt.Sprintf("SERVER_MEMORY=%d", d.Server.Build.MemoryLimit),
|
fmt.Sprintf("SERVER_MEMORY=%d", d.Server.Build.MemoryLimit),
|
||||||
fmt.Sprintf("SERVER_IP=%s", d.Server.Allocations.DefaultMapping.Ip),
|
fmt.Sprintf("SERVER_IP=%s", d.Server.Allocations.DefaultMapping.Ip),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user