mirror of
https://github.com/napnap75/multiarch-docker-images.git
synced 2025-12-15 19:24:19 +01:00
Corrected error following new docker client version
This commit is contained in:
@@ -8,14 +8,17 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"time"
|
"time"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/eclipse/paho.mqtt.golang"
|
"github.com/eclipse/paho.mqtt.golang"
|
||||||
)
|
)
|
||||||
|
|
||||||
func restartHandler(client mqtt.Client, msg mqtt.Message, dockerClient *client.Client, dockerContext context.Context) {
|
func restartHandler(client mqtt.Client, msg mqtt.Message, dockerClient *client.Client, dockerContext context.Context) {
|
||||||
fmt.Printf("Received message: %s from topic: %s\n", msg.Payload(), msg.Topic())
|
fmt.Printf("Received message: %s from topic: %s\n", msg.Payload(), msg.Topic())
|
||||||
var timeout = 30*time.Second
|
var timeout = int(30*time.Second)
|
||||||
err := dockerClient.ContainerRestart(dockerContext, string(msg.Payload()), &timeout)
|
var options container.StopOptions
|
||||||
|
options.Timeout = &timeout
|
||||||
|
err := dockerClient.ContainerRestart(dockerContext, string(msg.Payload()), options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Unable to restart container %s: %v\n", msg.Payload(), err)
|
fmt.Fprintf(os.Stderr, "Unable to restart container %s: %v\n", msg.Payload(), err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user