英文:
How beego(Go App Framework) will reload the application if there is any change in the conf file?
问题
我使用Golang Beego框架(http://beego.me/)开发了这个应用程序,并且它正在生产环境中运行。
假设我编辑了配置文件conf/app.conf,如何在不重新启动/重建应用程序的情况下重新加载我的应用程序?
我尝试使用'bee run'命令运行应用程序,但自动重新加载仍然没有成功。
英文:
I have developed the application using Golang Beego framework(http://beego.me/) and it is running in the production.
Suppose I edit the configuration file which is conf/app.conf, how can my app will be reloaded with restarting/rebuilding the application?
I tried to run the application using 'bee run' command but still no success in automatic reload.
答案1
得分: 1
你可以使用命令bee run
来运行该应用程序,并且它支持像这样的配置文件。
bee
命令默认通过文件扩展名来监视文件更改。你可以从源代码中看到var watchExts = []string{".go"}
。这意味着bee
将监视扩展名为.go
的文件,所以如果.go
文件发生更改,它将自动重新启动。
如果你想让bee
命令监视conf/app.conf
文件,你需要在你的应用程序目录下创建一个名为bee.json
的文件,并且内容应该像这样:
{
"version": 0,
"gopm": {
"enable": false,
"install": false
},
"go_install": false,
"watch_ext": [".conf"],
"dir_structure": {
"watch_all": false,
"controllers": "",
"models": "",
"others": []
},
"cmd_args": [],
"envs": [],
"database": {
"driver": "mysql"
}
}
英文:
You run the application with command bee run
and it supports config file like this.
bee
command watch file change default by file extension. You can see from the source code
. It means
var watchExts = []string{".go"}bee
will watch the file with extension .go
, so if .go
file change it will auto restarting.
If you want bee
command to watch the conf/app.conf
file, you need to make a file bee.json
at your app directory and the content should like this:
{
"version": 0,
"gopm": {
"enable": false,
"install": false
},
"go_install": false,
"watch_ext": [.conf],
"dir_structure": {
"watch_all": false,
"controllers": "",
"models": "",
"others": []
},
"cmd_args": [],
"envs": [],
"database": {
"driver": "mysql"
}
}
答案2
得分: 0
你可以使用gin,它非常容易设置:
gin是一个简单的命令行实用程序,用于实时重新加载Go Web应用程序。只需在应用程序目录中运行gin,你的Web应用程序将通过gin作为代理进行服务。当gin检测到更改时,它将自动重新编译你的代码。下次收到HTTP请求时,你的应用程序将重新启动。
英文:
You can use gin, it's really easy to set up:
> gin is a simple command line utility for live-reloading Go web applications. Just run gin in your app directory and your web app will be served with gin as a proxy. gin will automatically recompile your code when it detects a change. Your app will be restarted the next time it receives an HTTP request.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论