go: Integrating a more custom server with unit
Valentin V. Bartenev
vbart at nginx.com
Fri Dec 29 12:11:08 UTC 2017
On Friday, 29 December 2017 11:45:26 MSK Ingo Krabbe wrote:
> Good Morning group,
>
> I would like to try a little go web application with the unitd. The problem is, that I
>
> a) use custom TCP input (not http)
> b) and therefore I have unified the approach to open the http port(s) too.
>
> Actually I wrote a bit of code, that might also help you with your unit code,
> but what I want to know from you is, how I can add the port to unit, without using unit.ListenAndServe.
>
> http.ListenAndServe I use l := net.Listen and then http.Serve(l):
>
[..]
Unit interacts with the Go application using shared memory segments and a unix
socket pair for synchronization, it doesn't use TCP at all.
The arguments of function unit.ListenAndServe("port", nil) are ignored when
the application is run by the Unit daemon. They only needed when application
is run standalone (in this case it fallbacks to standard http.ListenAndServe()).
The idea is that all the networking should be configured, controlled, and
handled by Unit, while the application is only responsible for processing data.
Current version of Unit can only handle HTTP and only for ingoing connections.
In future, we plan to add support for ongoing connection and protocols like
WebSockets, generic TCP streams, and UDP. Probably, something else.
HTTP support is also planned to be improved, including TLS, HTTP/2, and QUIC.
So, knowing that your Go application doesn't open any TCP ports to interract
with Unit, are you able to integrate unit.ListenAndServe() in your code, or
you need something else? Does it make sense to you?
wbr, Valentin V. Bartenev
More information about the unit
mailing list