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条)

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?