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
|
Content-type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "test_1235",
|
"name": "test_1234",
|
||||||
"ssh_port": 46502,
|
"ssh_port": 46502,
|
||||||
"http_port": 46503,
|
"http_port": 46503,
|
||||||
"image": "docker.io/rosti/runtime:2020.04-1",
|
"image": "docker.io/rosti/runtime:2020.04-1",
|
||||||
@ -27,7 +27,7 @@ Content-type: application/json
|
|||||||
|
|
||||||
# Start
|
# Start
|
||||||
|
|
||||||
PUT http://localhost:1323/v1/apps/test_1234/start
|
PUT http://localhost:1323/v1/apps/test_4567/start
|
||||||
Content-type: application/json
|
Content-type: application/json
|
||||||
|
|
||||||
###
|
###
|
||||||
@ -50,15 +50,14 @@ Authorization: Token fee60059-f554-4c35-b44f-74b6be377095
|
|||||||
|
|
||||||
# Delete of app
|
# Delete of app
|
||||||
|
|
||||||
DELETE http://localhost:1323/v1/apps/test_1234
|
DELETE http://localhost:1323/v1/apps/test_4567
|
||||||
Content-type: application/json
|
Content-type: application/json
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
# Stats
|
# Processes
|
||||||
|
|
||||||
GET http://localhost:1323/v1/apps/test_1234/stats
|
GET http://localhost:1323/v1/apps/test_1234/processes
|
||||||
Content-type: application/json
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
@ -99,10 +98,7 @@ Content-type: application/json
|
|||||||
|
|
||||||
# Set password
|
# Set password
|
||||||
|
|
||||||
PUT http://localhost:1323/v1/apps/test_1235/keys
|
PUT http://localhost:1323/v1/apps/test_1234/keys
|
||||||
Content-type: application/json
|
Content-type: application/json
|
||||||
|
|
||||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmgl6/h44nBJciIX2xTO2ABzDDIU0apHQz6p8uLG2o4DBOXj4iVP5/kwTjcwQAJQBeqEHtjetnnamWbrChh8vu9VeIC8UIUpcf/iFKfhXZq3tJDXDLfiGsN/L/LmbsjhW84QRms0pUp9qV+wGP5+L7Qyws8NKFaODmK/FUFhanFhF2JxzAeMu492HvmfWmpDb0MdD8MwV58NAyd1N+ygh+QiirFx/NzFPWtQZpvBZvxCgtdNi9X6ajmYcvLregtovXQh4vwSGrNqpA5yyyNcR/JdsH2nqmUfsFo9mGs5et2s+TiZweGObsJBHX1dl4bV3oMPvtwh1zjA903jmQ0Bab cx@bimbo
|
testrr
|
||||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmgl6/h44nBJciIX2xTO2ABzDDIU0apHQz6p8uLG2o4DBOXj4iVP5/kwTjcwQAJQBeqEHtjetnnamWbrChh8vu9VeIC8UIUpcf/iFKfhXZq3tJDXDLfiGsN/L/LmbsjhW84QRms0pUp9qV+wGP5+L7Qyws8NKFaODmK/FUFhanFhF2JxzAeMu492HvmfWmpDb0MdD8MwV58NAyd1N+ygh+QiirFx/NzFPWtQZpvBZvxCgtdNi9X6ajmYcvLregtovXQh4vwSGrNqpA5yyyNcR/JdsH2nqmUfsFo9mGs5et2s+TiZweGObsJBHX1dl4bV3oMPvtwh1zjA903jmQ0Bab cx@bimbo
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,10 +53,11 @@ func (c *Container) GetState() (*apps.AppState, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu, memory, err := c.ResourceUsage()
|
// TODO: this implementation takes more than one hour for 470 containers. It needs to be implemented differently.
|
||||||
if err != nil {
|
// cpu, memory, err := c.ResourceUsage()
|
||||||
return nil, err
|
// if err != nil {
|
||||||
}
|
// return nil, err
|
||||||
|
// }
|
||||||
|
|
||||||
bytes, inodes, err := c.DiskUsage()
|
bytes, inodes, err := c.DiskUsage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -64,9 +65,11 @@ func (c *Container) GetState() (*apps.AppState, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
state := apps.AppState{
|
state := apps.AppState{
|
||||||
State: status,
|
State: status,
|
||||||
CPUUsage: cpu,
|
// CPUUsage: cpu,
|
||||||
MemoryUsage: memory,
|
// MemoryUsage: memory,
|
||||||
|
CPUUsage: -1.0,
|
||||||
|
MemoryUsage: -1.0,
|
||||||
DiskUsageBytes: bytes,
|
DiskUsageBytes: bytes,
|
||||||
DiskUsageInodes: inodes,
|
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 {
|
if quickServices.Memcached {
|
||||||
err = container.SetTechnology("memcached")
|
err = container.SetTechnology("memcached")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
6
main.go
6
main.go
@ -23,11 +23,15 @@ func main() {
|
|||||||
// Stats loop
|
// Stats loop
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
log.Println("Stats gathering started")
|
||||||
|
start := time.Now()
|
||||||
err := gatherStats()
|
err := gatherStats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("LOOP ERROR:", err.Error())
|
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)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
2
types.go
2
types.go
@ -29,6 +29,8 @@ type QuickServices struct {
|
|||||||
Python bool `json:"python"`
|
Python bool `json:"python"`
|
||||||
Node bool `json:"node"`
|
Node bool `json:"node"`
|
||||||
PHP bool `json:"php"`
|
PHP bool `json:"php"`
|
||||||
|
Ruby bool `json:"ruby"`
|
||||||
|
Deno bool `json:"deno"`
|
||||||
Memcached bool `json:"memcached"`
|
Memcached bool `json:"memcached"`
|
||||||
Redis bool `json:"redis"`
|
Redis bool `json:"redis"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user