Skip to content

Commit

Permalink
Merge pull request #6066 from mysteriumnetwork/fix/active-services
Browse files Browse the repository at this point in the history
Make services' activity status saving more consistent
  • Loading branch information
Zensey authored Aug 30, 2024
2 parents 1f879f5 + e4d497a commit 5938d83
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tequilapi/endpoints/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net/http"
"strconv"
"strings"
"sync"

"github.com/gin-gonic/gin"
"github.com/mysteriumnetwork/go-rest/apierror"
Expand All @@ -43,6 +44,7 @@ type ServiceEndpoint struct {
optionsParser map[string]services.ServiceOptionsParser
proposalRepository proposalRepository
tequilaApiClient *tequilapi_client.Client
activeServicesMu sync.Mutex
}

var (
Expand Down Expand Up @@ -249,6 +251,10 @@ func (se *ServiceEndpoint) ServiceStop(c *gin.Context) {
}

func (se *ServiceEndpoint) updateActiveServicesInUserConfig() {
// restrict concurrent update of ActiveServices property, so that statuses of all services are written the last
se.activeServicesMu.Lock()
defer se.activeServicesMu.Unlock()

runningInstances := se.serviceManager.List(false)
activeServices := make([]string, len(runningInstances))
for i, service := range runningInstances {
Expand Down

0 comments on commit 5938d83

Please sign in to comment.