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:
Adam Štrauch 2021-04-02 18:10:34 +02:00
parent bc7969bcce
commit 8eb1f47f2c
Signed by: cx
GPG Key ID: 018304FFA8988F8D
5 changed files with 38 additions and 19 deletions

View File

@ -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

View File

@ -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 {
@ -64,9 +65,11 @@ func (c *Container) GetState() (*apps.AppState, error) {
}
state := apps.AppState{
State: status,
CPUUsage: cpu,
MemoryUsage: memory,
State: status,
// CPUUsage: cpu,
// MemoryUsage: memory,
CPUUsage: -1.0,
MemoryUsage: -1.0,
DiskUsageBytes: bytes,
DiskUsageInodes: inodes,
}

View File

@ -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 {

View File

@ -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)
}
}()

View File

@ -29,6 +29,8 @@ type QuickServices struct {
Python bool `json:"python"`
Node bool `json:"node"`
PHP bool `json:"php"`
Ruby bool `json:"ruby"`
Deno bool `json:"deno"`
Memcached bool `json:"memcached"`
Redis bool `json:"redis"`
}