英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论