How to run a function before App start in Revel Go Web Framework

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

How to run a function before App start in Revel Go Web Framework

问题

我正在使用Revel开发一个Go应用程序,我想知道如何在应用程序加载之前运行一个函数,或者类似的操作。我知道Revel提供了revel.OnAppStart,但它只在我们访问任何URL时才运行。我想要的是在运行命令revel run myApp时立即调用该函数,而不需要额外的操作。

英文:

I am using Revel for developing a Go application, I was wondering how can I run a function just before App Loads or something like that. I know Revel provides revel.OnAppStart but it runs only when we hit any URL. What I want is to call the function as soon as I run the command revel run myApp without any extra things to do.

答案1

得分: 0

我从社区支持中得到了答案...revel.OnAppStart按预期运行...但只有在环境为PROD时才能运行,而在DEV环境下不能运行...因为在测试中,只有在有请求时代理才会启动应用程序。

英文:

I got the answer from community support...revel.OnAppStart runs as expected...but only when the environment is PROD not on DEV...because in testing the app is only started by the proxy when there's a request.

huangapple
  • 本文由 发表于 2017年5月29日 15:54:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/44237297.html
匿名

发表评论

匿名网友

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

确定