MM-56611: Move license expiration check to be synchronous (#26010)

During server start, runLicenseExpirationCheckJob was being called
from a goroutine which would eventually call SetLicense and iterate
through the ps.licenseListeners.

But at the same time doElasticsearchFixChannelIndex would also
call AddLicenseListener and try to edit the ps.licenseListeners map,
leading to a race condition.

To fix this, we simply move the runLicenseExpirationCheckJob
to be synchronous. This fixes the race, and also improves
the correctness because after 1f431bf722
there was no license check being done synchronously during server boot.

So theoretically, the server might go on doing some stuff
until the Go runtime decides to run the license check goroutine.

https://mattermost.atlassian.net/browse/MM-56611

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2024-01-24 11:59:42 +05:30
коммит произвёл GitHub
родитель 2d7a14244f
Коммит 6d41ee171e

Просмотреть файл

@@ -529,9 +529,9 @@ func NewServer(options ...Option) (*Server, error) {
}
func (s *Server) runJobs() {
s.runLicenseExpirationCheckJob()
s.Go(func() {
appInstance := New(ServerConnector(s.Channels()))
s.runLicenseExpirationCheckJob()
runDNDStatusExpireJob(appInstance)
runPostReminderJob(appInstance)
})