One litle-publicized feature of the BeeGo Go framework is its admin dashboard.
Features
Although it may look quite raw visually (think MIME: text/plain), it contains a wealth of information about goroutines, threads, memory usage, and request statistics. It even allows devs to add to a "healthcheck" list, and admins allowed dashboard access to run "tasks" defined in code. The diagram belows shows the hierarchy of features in the version coming with Beego 1.3.0.
Enabling and customizing the admin dashboard
The admin dashboard is not enabled by default. Its availability is controlled by the EnableAdmin
global. The simplest (best ?) way to configure it is arguably to add it to the confg/app.conf
configuration file:
For the curious reader, the config loading happens in beego/config.ParseConfig()
, which is itself triggered by beego/config init()
, meaning it runs before the application main().
Some degree of configuration is available, via the two additional variables: AdminHttpAddr
which take an IP address/name string (default: 127.0.01
), and AdminHttpPort
, which takes an integer port number (default: 8088).
Adding application health checks runnable from the admin dashboard
The dashboard provides access to a "healthcheck" section, allowing app developers to add their custom sanity checks on the running application.
Health checks are defined by the minimal The dashboard-triggered healthcheck works by iterating on the checks in HealthChecker
interface, and stored in the AdminCheckList
map. Although the AddHealthCheck()
:
// See beego/toolbox/healthcheck.go
type HealthChecker interface {
Check() error
}
// add health checker with name string
func AddHealthCheck(name string, hc HealthChecker) {
AdminCheckList[name] = hc
}
AdminCheckList
, and printing the results from each check which returned a non-nil error.