Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

Feature: Support unix sockets #41

Open
ChrisLundquist opened this issue Sep 14, 2018 · 0 comments
Open

Feature: Support unix sockets #41

ChrisLundquist opened this issue Sep 14, 2018 · 0 comments

Comments

@ChrisLundquist
Copy link

ChrisLundquist commented Sep 14, 2018

An example unix socket server:
https://gist.github.com/teknoraver/5ffacb8757330715bcbcc90e6d46ac74

The punch line is:

	server := http.Server{
		Handler: http.FileServer(http.Dir(root)),
	}

	unixListener, err := net.Listen("unix", os.Args[1])
	if err != nil {
		panic(err)
	}
	server.Serve(unixListener)

I tried this here and sadly our types don't match net.http's interface.
From: https://golang.org/pkg/net/http/#Server
func (srv *Server) Serve(l net.Listener) error

However here, we're asking for func Serve(servers ...*http.Server)
and then we hardcode tcp

		l, err := a.net.Listen("tcp", s.Addr)

here in listen

It seems like we should match net.http here and take a https://golang.org/pkg/net/#Listener which would allow us to grab https://golang.org/pkg/net/#Addr so we can open tcp/udp/unix as appropriate.

I could be missing something, but I didn't see anything too TCP specific in the fork/exec/inherit code.

My use case is that I want to front multiple versions of the same service with nginx, and I don't want to play games with ports.
While that particular case is admittedly a little wacky, fronting a service with nginx or the like isn't too unreasonable (say for handling auth somewhere else).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant