GAE Flex Golang开发环境

huangapple go评论100阅读模式
英文:

GAE Flex Golang Development Env

问题

我曾经使用Golang开发GAE标准版应用程序,现在我转移到了新的GAE Flex与Golang。我在开发环境中遇到了一些困惑和问题,主要如下:

  1. 在本地服务器上运行应用程序
    GAE标准版(使用go_appengine APIs)

~/go_appengine/goapp serve .

GAE Flex(根据官方文档,使用Golang标准运行时)

go run *.go

在GAE标准版中,一切都是在专有的API下构建和运行的,工作正常。然而,在GAE Flex中,我遇到了运行时问题,每次更改代码都需要停止服务器并重新启动go run *.go

如何在代码更改时自动重新启动Golang服务器?

  1. 在app.yaml中设置static_dir
    GAE标准版(使用go_appengine APIs)

`handlers:

  • url: /static
    static_dir: houston/_template/_static`

这个方法可以正常工作。

GAE Flex

`handlers:

  • url: /static
    static_dir: houston/_template/_static`

这个方法不起作用(因为没有像GAE标准版那样的API)。

Golang如何为GAE Flex提供静态文件和static_dir的服务?

英文:

I used to develop the application with GAE Standard using Golang and now I moved to the new GAE Flex with Golang. I have some confused issues and problem mainly in development environment as follows:

  1. Running the application in local server
    GAE Standard (Using go_appengine APIs)

~/go_appengine/goapp serve .

GAE Flex (based on the official document, using Golang standard runtime)

go run *.go

In case of GAE standard, everything is build and run under proprietary APIs which works fine. Anyway, in GAE Flex, I struck on the runtime problem where I need to stop server and start go run *.go everytime I changed the code.

How to run Golang server locally without manually restart server everytime when the code has changed?

  1. Setting up static_dir in app.yaml
    GAE Standard (Using go_appengine APIs)

`handlers:

  • url: /static
    static_dir: houston/_template/_static`

It works fine.

GAE Flex

`handlers:

  • url: /static
    static_dir: houston/_template/_static`

It does not work (regarding no APIs like GAE Standard)

How Golang serves static_files and static_dir for GAE Flex?

答案1

得分: 0

我找到了一些解决方案。使用Gulp,你可以解决这些任务。实际上,当一个go文件被修改时,一个任务会将应用程序编译到'bin'文件夹中,然后另一个任务会启动可执行文件。

https://medium.com/@etiennerouzeaud/autoreload-your-go-webserver-with-gulp-ee5e231d133d

英文:

I have found some of solution. With Gulp you can solve this tasks. Indeed, when a go file is modified, a task compile the application in the 'bin' folder then another launch the executable.

https://medium.com/@etiennerouzeaud/autoreload-your-go-webserver-with-gulp-ee5e231d133d

huangapple
  • 本文由 发表于 2017年4月27日 19:23:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/43656387.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定