Open simonw opened 2 years ago
What was the confusing behavior? That image just spits out some JSON, but the main reason we use it is its auto-idle behavior. An nginx image will stay up forever until you stop it. Of course, we could put this auto-idle proxy in front of nginx. Maybe this is a better idea.
That was the problem - the auto-idling meant that when I went to look at my list of machines it was in "stopped" state, despite me having recently launched it, which was a surprise.
I think the real problem is that the text didn't explain this was going to happen. Adding a paragraph explaining what's happening there (and how the fastify-functions
container works) would have clarified things for me.
Did a bit more digging around this - understanding how the tired-proxy
mechanism worked was really helpful: https://gist.github.com/simonw/dadf9d218e8cf4f6a84161de45092e3c
I think it'd be helpful if we could see the source code for flyio/fastify-functions
to understand how it idles itself. My initial thought was that we should exit the process with code 0, but maybe we're just supposed to unbind from the port? I've seen both as examples. Maybe both are ok?
I found the fastify-functions source code but looks like the important part is actually in tired-proxy where they exit(0)
to idle. Still a bit confused though because bfaas unbinds the server and has the exit command commented out.
I've been following the Machines tutorial. It suggested running an image using
flyio/fastify-functions
- I'm not entirely sure what that is, but https://hub.docker.com/r/flyio/fastify-functions says:At any rate, I found its behaviour confusing. I had more success following that tutorial by switching that out for https://hub.docker.com/r/nginxdemos/hello/
Running that in place of
flyio/fastify-functions
gave me a page on the IPv4 address I had allocated which showed me the NGINX debug page and demonstrated that everything was working correctly.