environment(docker): fix timeout when sending a stop signal
Previously, Docker would terminate the container when it's stop configuration was configured to send a signal to the container. This was due to Docker's API wanting the value as a duration string (`1s`) rather than a number, so our value of `-1` was being formatted to `0s` rather than `-1s` like we needed. Closes https://github.com/pterodactyl/panel/issues/4555
This commit is contained in:
parent
1457470fff
commit
2fd0edbff9
|
@ -179,8 +179,12 @@ func (e *Environment) Stop(ctx context.Context) error {
|
|||
|
||||
// Allow the stop action to run for however long it takes, similar to executing a command
|
||||
// and using a different logic pathway to wait for the container to stop successfully.
|
||||
t := time.Duration(-1)
|
||||
if err := e.client.ContainerStop(ctx, e.Id, &t); err != nil {
|
||||
//
|
||||
// Using a negative timeout here will allow the container to stop gracefully,
|
||||
// rather than forcefully terminating it, this value MUST be at least 1
|
||||
// second, otherwise it will be ignored.
|
||||
timeout := -1 * time.Second
|
||||
if err := e.client.ContainerStop(ctx, e.Id, &timeout); err != nil {
|
||||
// If the container does not exist just mark the process as stopped and return without
|
||||
// an error.
|
||||
if client.IsErrNotFound(err) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user