Golang production web application configuration

前端 未结 4 1671
感情败类
感情败类 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条回答
  •  猫巷女王i
    2020-12-04 05:01

    For those who want simple go app running as a daemon, use systemd (Supported by many linux distros) instead of Upstart.

    Create a service file at

    touch /etc/systemd/system/my-go-daemon.service
    

    Enter

    [Unit]
    Description=My Go App
    
    [Service]
    Type=simple
    WorkingDirectory=/my/go/app/directory
    ExecStart=/usr/lib/go run main.go 
    
    [Install]
    WantedBy=multi-user.target
    

    Then enable and start the service

    systemctl enable my-go-daemon
    systemctl start my-go-daemon
    systemctl status my-go-daemon
    

    systemd has a separate journaling system that will let you tail logs for easy trouble-shooting.

提交回复
热议问题