Permalink
Browse files

Adding the number of containers count

  • Loading branch information...
MohamedBassem committed Jul 10, 2015
1 parent 61b4e4e commit 9b3a74be12c8b337b896896226ff71885cfa9f1a
Showing with 17 additions and 2 deletions.
  1. +5 −1 cmd/getaredis-server/server.go
  2. +2 −1 cmd/getaredis-server/templates/index.tmpl
  3. +10 −0 instances.go
@@ -40,7 +40,11 @@ func main() {
m.Use(render.Renderer())
m.Get("/", func(r render.Render) {
r.HTML(200, "index", "")
count, err := ctx.CountContainers(true)
if err != nil {
count = -1
}
r.HTML(200, "index", count)
})
m.Post("/instance", func(res http.ResponseWriter, req *http.Request) (int, string) {
@@ -72,8 +72,9 @@
</div>
</header>
<div id="footer" style="height:52.5px;text-align:center;width:100%;">
<div id="footer" style="height:70px;text-align:center;width:100%;">
* Limited to 5 connections per instance. <br/>
{{.}} Redis instances started so far ..<br/>
Developed by <a href="http://mbassem.com">Mohamed Bassem</a> <br/>
</div>
</body>
View
@@ -112,3 +112,13 @@ func (ctx *context) RemoveContainer(hostIP, id string) error {
})
return err
}
func (ctx *context) CountContainers(includeNotRunning bool) (int, error) {
var count = -1
var where string
if !includeNotRunning {
where = "running = 1"
}
err := ctx.db.Model(&Instance{}).Where(where).Count(&count)
return count, err.Error
}

0 comments on commit 9b3a74b

Please sign in to comment.