GAE/Go在本地开发服务器上挂断电话。

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

GAE/Go hang up on local development server

问题

我正在开发GAE/Go + gin应用程序。

我们现在有大约25个类似这样的处理程序。

func init() {
    r := gin.New()
    r.POST("/path/to/some1", func1)   //  ^
    r.POST("/path/to/some2", func2)   //  |
            :                         //  | 大约有25个处理程序
    r.POST("/path/to/someX", funcX)   //  v
}

我在上面的代码中添加了另一个处理程序funcY,然后我调用了本地开发服务器,但在启动过程中卡住了。

func init() {                         // 在启动过程中卡住了。
    r := gin.New()
    r.POST("/path/to/some1", func1)   
    r.POST("/path/to/some2", func2)   
            :                         
    r.POST("/path/to/someX", funcX)   
    r.POST("/path/to/someY", funcY)   
}

控制台日志如下。之后没有任何消息。

"C:\Program Files (x86)\JetBrains\Gogland 171.3780.106\bin\runnerw.exe" C:/go_appengine\goapp.bat serve C:/path/to/app.yaml
INFO     2017-05-26 15:03:02,552 devappserver2.py:764] Skipping SDK update check.
INFO     2017-05-26 15:03:02,996 api_server.py:268] Starting API server at: http://localhost:56094
INFO     2017-05-26 15:03:03,000 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO     2017-05-26 15:03:03,000 admin_server.py:116] Starting admin server at: http://localhost:8000

funcY没有问题,因为当我移除func1时,它可以正常启动。

func init() {                         // 这个可以正常工作。
    r := gin.New()
    r.POST("/path/to/some2", func2)   
            :                         
    r.POST("/path/to/someX", funcX)   
    r.POST("/path/to/someY", funcY)   
}

gin是否有处理程序的最大数量限制?如果有,我该如何提高它?或者我还有其他解决方法吗?

[更新]
这似乎是本地开发服务器的问题。当我部署到实际的GAE时,我的应用程序可以正常工作。我该如何解决本地开发服务器的这个问题?

英文:

I am developing GAE/Go + gin application.

We have now about 25 handlers like this.

func init() {
    r := gin.New()
	r.POST("/path/to/some1", func1)   //  ^
	r.POST("/path/to/some2", func2)   //  |
			:                         //  | about 25 handlers
	r.POST("/path/to/someX", funcX)   //  v
}

I added another handler funcY to above code. and I invoked local development server, but it hangs up during start up.

func init() {                         // Hang up during start up.
    r := gin.New()
	r.POST("/path/to/some1", func1)   
	r.POST("/path/to/some2", func2)   
			:                         
	r.POST("/path/to/someX", funcX)   
	r.POST("/path/to/someY", funcY)   
}

The console log is as below. No message after this.

"C:\Program Files (x86)\JetBrains\Gogland 171.3780.106\bin\runnerw.exe" C:/go_appengine\goapp.bat serve C:/path/to/app.yaml
INFO     2017-05-26 15:03:02,552 devappserver2.py:764] Skipping SDK update check.
INFO     2017-05-26 15:03:02,996 api_server.py:268] Starting API server at: http://localhost:56094
INFO     2017-05-26 15:03:03,000 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO     2017-05-26 15:03:03,000 admin_server.py:116] Starting admin server at: http://localhost:8000

funcY has no problem because when I remove func1, it starts up normally.

func init() {                         // This works without problem.
    r := gin.New()
	r.POST("/path/to/some2", func2)   
			:                         
	r.POST("/path/to/someX", funcX)   
	r.POST("/path/to/someY", funcY)   
}

Does gin have maximum number of handler? If so, how can I raise it? Or do I have another way to solve this?

[UPDATE]
This looks to be the local development server problem. When I deployed to the actual GAE, my app works without problem. How can I solve this problem in the local development server?

答案1

得分: 0

自行解决。

我将gin设置为release mode,我的应用程序正常工作。

gin.SetMode(gin.ReleaseMode)
英文:

Self resolved.

I set gin to release mode and my app works fine.

gin.SetMode(gin.ReleaseMode)

huangapple
  • 本文由 发表于 2017年5月26日 14:18:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/44194886.html
匿名

发表评论

匿名网友

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

确定