Skip to content

shutdown signal ServerUnix #123

@tiolan

Description

@tiolan

Hey, I am using the following code for my own Docker log-plugin:

package main
import (
	"fmt"
	"github.com/docker/go-plugins-helpers/sdk"
)
func main() {
	h := sdk.NewHandler('{"Implements": ["LoggingDriver"]}')
	handlers(&h, newDriver())
	if err := h.ServeUnix("logdriver", 0); err != nil {
		fmt.Println("Ending Go main with PANIC")
		panic(err)
	}
	fmt.Println("Ending Go main")
}

It seems, that ServeUnix is the blocking call, as it does not return.
I would expect, that when invoking docker plugin disable driver:v1, it returns and one of the lines

"Ending Go main with PANIC"

or

"Ending Go main"

is visible in the stdout of the plugin (meaning in the logs of Dockerd).
Note: I can see other logs from this plugin using fmt.Println in Dockerd logs, so logging works.

I guess, that ServeUnix does not handle shutdown signals. Do I need to do it manually?

BTW: In the documentation of server.Serve, which is called inside sdk.ServeUnix, they say:

Serve always returns a non-nil error. After Shutdown or Close, the returned error is ErrServerClosed.

So, is the if err := h.ServeUnix("logdriver", 0); err != nil { wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions