Golang production web application configuration

前端 未结 4 1668
感情败类
感情败类 2020-12-04 04:21

For those of you running Go backends in production:

What is your stack / configuration for running a Go web application?

I haven\'t seen much on this topic b

4条回答
  •  感动是毒
    2020-12-04 05:13

    nginx for:

    • Reverse HTTP proxy to my Go application
    • Static file handling
    • SSL termination
    • HTTP headers (Cache-Control, et. al)
    • Access logs (and therefore leveraging system log rotation)
    • Rewrites (naked to www, http:// to https://, etc.)

    nginx makes this very easy, and although you can serve directly from Go thanks to net/http, there's a lot of "re-inventing the wheel" and stuff like global HTTP headers involves some boilerplate you can probably avoid.

    supervisord for managing my Go binary. Ubuntu's Upstart (as mentioned by Mostafa) is also good, but I like supervisord as it's relatively distro-agnostic and is well documented.

    Supervisord, for me:

    • Runs my Go binary as needed
    • Brings it up after a crash
    • Holds my environmental variables (session auth keys, etc.) as part of a single config.
    • Runs my DB (to make sure my Go binary isn't running without it)

提交回复
热议问题