Merge pull request 'don't fetch metrics for non running servers' (#56) from lastFixes into trunk
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #56 Reviewed-by: Sarah Jamie Lewis <sarah@openprivacy.ca>
This commit is contained in:
commit
a1e06a868f
10
.drone.yml
10
.drone.yml
|
@ -5,7 +5,7 @@ name: linux-android-windows-test
|
|||
|
||||
steps:
|
||||
- name: fetch
|
||||
image: golang
|
||||
image: golang:1.17.5
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /go
|
||||
|
@ -23,7 +23,7 @@ steps:
|
|||
- echo `date +%G-%m-%d-%H-%M` > BUILDDATE
|
||||
|
||||
- name: quality
|
||||
image: golang
|
||||
image: golang:1.17.5
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /go
|
||||
|
@ -33,7 +33,7 @@ steps:
|
|||
#Todo: fix all the lint errors and add `-set_exit_status` above to enforce linting
|
||||
|
||||
- name: build-linux
|
||||
image: golang
|
||||
image: golang:1.17.5
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /go
|
||||
|
@ -62,6 +62,7 @@ steps:
|
|||
|
||||
- name: deploy-buildfiles
|
||||
image: kroniak/ssh-client
|
||||
pull: if-not-exists
|
||||
environment:
|
||||
BUILDFILES_KEY:
|
||||
from_secret: buildfiles_key
|
||||
|
@ -86,6 +87,7 @@ steps:
|
|||
|
||||
- name: gitea-release
|
||||
image: plugins/gitea-release
|
||||
pull: if-not-exists
|
||||
when:
|
||||
event: tag
|
||||
settings:
|
||||
|
@ -104,6 +106,7 @@ steps:
|
|||
|
||||
- name: notify-email
|
||||
image: drillster/drone-email
|
||||
pull: if-not-exists
|
||||
settings:
|
||||
host: build.openprivacy.ca
|
||||
port: 25
|
||||
|
@ -114,6 +117,7 @@ steps:
|
|||
|
||||
- name: notify-gogs
|
||||
image: openpriv/drone-gogs
|
||||
pull: if-not-exists
|
||||
when:
|
||||
event: pull_request
|
||||
status: [ success, changed, failure ]
|
||||
|
|
|
@ -144,6 +144,11 @@ func (sf *ServersFunctionality) DeleteServer(onion string, currentPassword strin
|
|||
|
||||
func (sf *ServersFunctionality) LaunchServer(onion string) {
|
||||
appServers.LaunchServer(onion)
|
||||
server := appServers.GetServer(onion)
|
||||
if server != nil {
|
||||
newStats := server.GetStatistics()
|
||||
publishFn(event.NewEventList(ServerStatsUpdate, event.Identity, onion, TotalMessages, strconv.Itoa(newStats.TotalMessages), Connections, strconv.Itoa(newStats.TotalConnections)))
|
||||
}
|
||||
}
|
||||
|
||||
func (sf *ServersFunctionality) StopServer(onion string) {
|
||||
|
@ -195,10 +200,12 @@ func cacheForwardServerMetricUpdates() {
|
|||
serverList := appServers.ListServers()
|
||||
for _, serverOnion := range serverList {
|
||||
server := appServers.GetServer(serverOnion)
|
||||
newStats := server.GetStatistics()
|
||||
if stats, ok := cache[serverOnion]; !ok || stats.TotalConnections != newStats.TotalConnections || stats.TotalMessages != newStats.TotalMessages {
|
||||
cache[serverOnion] = newStats
|
||||
publishFn(event.NewEventList(ServerStatsUpdate, event.Identity, serverOnion, TotalMessages, strconv.Itoa(newStats.TotalMessages), Connections, strconv.Itoa(newStats.TotalConnections)))
|
||||
if running, err := server.CheckStatus(); running && err == nil {
|
||||
newStats := server.GetStatistics()
|
||||
if stats, ok := cache[serverOnion]; !ok || stats.TotalConnections != newStats.TotalConnections || stats.TotalMessages != newStats.TotalMessages {
|
||||
cache[serverOnion] = newStats
|
||||
publishFn(event.NewEventList(ServerStatsUpdate, event.Identity, serverOnion, TotalMessages, strconv.Itoa(newStats.TotalMessages), Connections, strconv.Itoa(newStats.TotalConnections)))
|
||||
}
|
||||
}
|
||||
}
|
||||
case <-killStatsUpdate:
|
||||
|
|
5
go.mod
5
go.mod
|
@ -3,8 +3,8 @@ module git.openprivacy.ca/cwtch.im/libcwtch-go
|
|||
go 1.15
|
||||
|
||||
require (
|
||||
cwtch.im/cwtch v0.14.8
|
||||
git.openprivacy.ca/cwtch.im/server v1.4.1
|
||||
cwtch.im/cwtch v0.14.9
|
||||
git.openprivacy.ca/cwtch.im/server v1.4.2
|
||||
git.openprivacy.ca/openprivacy/connectivity v1.5.0
|
||||
git.openprivacy.ca/openprivacy/log v1.0.3
|
||||
github.com/mutecomm/go-sqlcipher/v4 v4.4.2
|
||||
|
@ -12,3 +12,4 @@ require (
|
|||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
)
|
||||
|
||||
|
|
4
go.sum
4
go.sum
|
@ -14,11 +14,15 @@ cwtch.im/cwtch v0.14.1/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI=
|
|||
cwtch.im/cwtch v0.14.1/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI=
|
||||
cwtch.im/cwtch v0.14.8 h1:bybtnnCTp7utGvfIbQvdeffKmJQgGrkfgijrAfS8SQw=
|
||||
cwtch.im/cwtch v0.14.8/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI=
|
||||
cwtch.im/cwtch v0.14.9 h1:VYXbQG6f41fCoLpLEYDAeiJSG+9Gxstl1DOk1Hv4tjM=
|
||||
cwtch.im/cwtch v0.14.9/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
|
||||
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
|
||||
git.openprivacy.ca/cwtch.im/server v1.4.1 h1:ZCySCYxt7rvCLdf2INFWK1xDoSexJD6sJRZ2yZ9iYHU=
|
||||
git.openprivacy.ca/cwtch.im/server v1.4.1/go.mod h1:gJ57TXx0cnnKN7FZSzr210KNq+WtDtBUo1zHFZ/FbTw=
|
||||
git.openprivacy.ca/cwtch.im/server v1.4.2 h1:ZcRK1XuWvJzNjYdAvAISD8HcEITPwWbvRiIZGkMKu1k=
|
||||
git.openprivacy.ca/cwtch.im/server v1.4.2/go.mod h1:CeE/bThy2UVQ+gx+3ctNt65H9xvELDfcwBS9qJwOsOg=
|
||||
git.openprivacy.ca/cwtch.im/tapir v0.4.9 h1:LXonlztwvI1F1++0IyomIcDH1/Bxzo+oN8YjGonNvjM=
|
||||
git.openprivacy.ca/cwtch.im/tapir v0.4.9/go.mod h1:p4bHo3DAO8wwimU6JAeZXbfPQ4jnoA2bV+4YvknWTNQ=
|
||||
git.openprivacy.ca/openprivacy/bine v0.0.4 h1:CO7EkGyz+jegZ4ap8g5NWRuDHA/56KKvGySR6OBPW+c=
|
||||
|
|
Reference in New Issue