Various changes
* Stop using docker stats API (no replacement yet) * Ruby and Deno support * Meassure how much time stats loading takes
This commit is contained in:
parent
bc7969bcce
commit
8eb1f47f2c
18
api.http
18
api.http
@ -3,7 +3,7 @@ Authorization: Token fee60059-f554-4c35-b44f-74b6be377095
|
||||
Content-type: application/json
|
||||
|
||||
{
|
||||
"name": "test_1235",
|
||||
"name": "test_1234",
|
||||
"ssh_port": 46502,
|
||||
"http_port": 46503,
|
||||
"image": "docker.io/rosti/runtime:2020.04-1",
|
||||
@ -27,7 +27,7 @@ Content-type: application/json
|
||||
|
||||
# Start
|
||||
|
||||
PUT http://localhost:1323/v1/apps/test_1234/start
|
||||
PUT http://localhost:1323/v1/apps/test_4567/start
|
||||
Content-type: application/json
|
||||
|
||||
###
|
||||
@ -50,15 +50,14 @@ Authorization: Token fee60059-f554-4c35-b44f-74b6be377095
|
||||
|
||||
# Delete of app
|
||||
|
||||
DELETE http://localhost:1323/v1/apps/test_1234
|
||||
DELETE http://localhost:1323/v1/apps/test_4567
|
||||
Content-type: application/json
|
||||
|
||||
###
|
||||
|
||||
# Stats
|
||||
# Processes
|
||||
|
||||
GET http://localhost:1323/v1/apps/test_1234/stats
|
||||
Content-type: application/json
|
||||
GET http://localhost:1323/v1/apps/test_1234/processes
|
||||
|
||||
###
|
||||
|
||||
@ -99,10 +98,7 @@ Content-type: application/json
|
||||
|
||||
# Set password
|
||||
|
||||
PUT http://localhost:1323/v1/apps/test_1235/keys
|
||||
PUT http://localhost:1323/v1/apps/test_1234/keys
|
||||
Content-type: application/json
|
||||
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmgl6/h44nBJciIX2xTO2ABzDDIU0apHQz6p8uLG2o4DBOXj4iVP5/kwTjcwQAJQBeqEHtjetnnamWbrChh8vu9VeIC8UIUpcf/iFKfhXZq3tJDXDLfiGsN/L/LmbsjhW84QRms0pUp9qV+wGP5+L7Qyws8NKFaODmK/FUFhanFhF2JxzAeMu492HvmfWmpDb0MdD8MwV58NAyd1N+ygh+QiirFx/NzFPWtQZpvBZvxCgtdNi9X6ajmYcvLregtovXQh4vwSGrNqpA5yyyNcR/JdsH2nqmUfsFo9mGs5et2s+TiZweGObsJBHX1dl4bV3oMPvtwh1zjA903jmQ0Bab cx@bimbo
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmgl6/h44nBJciIX2xTO2ABzDDIU0apHQz6p8uLG2o4DBOXj4iVP5/kwTjcwQAJQBeqEHtjetnnamWbrChh8vu9VeIC8UIUpcf/iFKfhXZq3tJDXDLfiGsN/L/LmbsjhW84QRms0pUp9qV+wGP5+L7Qyws8NKFaODmK/FUFhanFhF2JxzAeMu492HvmfWmpDb0MdD8MwV58NAyd1N+ygh+QiirFx/NzFPWtQZpvBZvxCgtdNi9X6ajmYcvLregtovXQh4vwSGrNqpA5yyyNcR/JdsH2nqmUfsFo9mGs5et2s+TiZweGObsJBHX1dl4bV3oMPvtwh1zjA903jmQ0Bab cx@bimbo
|
||||
|
||||
|
||||
testrr
|
||||
|
@ -53,10 +53,11 @@ func (c *Container) GetState() (*apps.AppState, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cpu, memory, err := c.ResourceUsage()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TODO: this implementation takes more than one hour for 470 containers. It needs to be implemented differently.
|
||||
// cpu, memory, err := c.ResourceUsage()
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
bytes, inodes, err := c.DiskUsage()
|
||||
if err != nil {
|
||||
@ -65,8 +66,10 @@ func (c *Container) GetState() (*apps.AppState, error) {
|
||||
|
||||
state := apps.AppState{
|
||||
State: status,
|
||||
CPUUsage: cpu,
|
||||
MemoryUsage: memory,
|
||||
// CPUUsage: cpu,
|
||||
// MemoryUsage: memory,
|
||||
CPUUsage: -1.0,
|
||||
MemoryUsage: -1.0,
|
||||
DiskUsageBytes: bytes,
|
||||
DiskUsageInodes: inodes,
|
||||
}
|
||||
|
14
handlers.go
14
handlers.go
@ -312,6 +312,20 @@ func setServicesHandler(c echo.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
if quickServices.Ruby {
|
||||
err = container.SetTechnology("ruby")
|
||||
if err != nil {
|
||||
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
|
||||
}
|
||||
}
|
||||
|
||||
if quickServices.Deno {
|
||||
err = container.SetTechnology("deno")
|
||||
if err != nil {
|
||||
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
|
||||
}
|
||||
}
|
||||
|
||||
if quickServices.Memcached {
|
||||
err = container.SetTechnology("memcached")
|
||||
if err != nil {
|
||||
|
6
main.go
6
main.go
@ -23,11 +23,15 @@ func main() {
|
||||
// Stats loop
|
||||
go func() {
|
||||
for {
|
||||
log.Println("Stats gathering started")
|
||||
start := time.Now()
|
||||
err := gatherStats()
|
||||
if err != nil {
|
||||
log.Println("LOOP ERROR:", err.Error())
|
||||
}
|
||||
time.Sleep(5 * time.Minute)
|
||||
elapsed := time.Since(start)
|
||||
log.Printf("Stats gathering elapsed time: %.2fs\n", elapsed.Seconds())
|
||||
time.Sleep(30 * time.Second)
|
||||
}
|
||||
}()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user