dongling0519 2018-01-27 18:27
浏览 266
已采纳

在Ubuntu / Centos上部署和运行Go API服务器

I just finished my first backend with Go using Iris framework but now I need to put it on production so I can use it in the Slack app I built.

In order to test the code locally I only run my file with go run main.go and ngrok to test with the Slack API, it's working and it's finished.

I have a droplet with Ubuntu 16.04.3 and other one with Centos 7... I was searching for something like pm2 for go, running the server and using nginx to point that port but I read that with Go it's different and I have to use something like this https://fabianlee.org/2017/05/21/golang-running-a-go-binary-as-a-systemd-service-on-ubuntu-16-04/

But that's a very long configuration for a simple server and my questions are:

  • Is this the usual way to config the APIs with Go?
  • Apart of DigitalOcean, do you recommend to use a different service to run my API?

This is really my first time with Go and I just want to learn more, I am a backend developer with Laravel and NodeJS.

  • 写回答

2条回答 默认 最新

  • dongzhe6287 2018-01-27 19:40
    关注

    I think most people use Supervisor for this purpose, including me.

    To make it very easy for you, just take a look at my Golang project, isaac-racing-server and use it as a template for yours by replacing isaac-racing-server with the name of your app. (The Supervisor files are in a subdirectory.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题