• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-server / 1622978334

13 Jan 2025 03:51PM UTC coverage: 72.802% (-3.8%) from 76.608%
1622978334

Pull #300

gitlab-ci

alfrunes
fix: Deployment device count should not exceed max devices

Added a condition to skip deployments when the device count reaches max
devices.

Changelog: Title
Ticket: MEN-7847
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Pull Request #300: fix: Deployment device count should not exceed max devices

4251 of 6164 branches covered (68.96%)

Branch coverage included in aggregate %.

0 of 18 new or added lines in 1 file covered. (0.0%)

2544 existing lines in 83 files now uncovered.

42741 of 58384 relevant lines covered (73.21%)

21.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/backend/services/reporting/app/server/server.go
1
// Copyright 2022 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
package server
16

17
import (
18
        "context"
19
        "net/http"
20
        "os"
21
        "os/signal"
22
        "time"
23

24
        "golang.org/x/sys/unix"
25

26
        "github.com/gin-gonic/gin"
27

28
        "github.com/mendersoftware/mender-server/pkg/config"
29
        "github.com/mendersoftware/mender-server/pkg/log"
30

31
        api "github.com/mendersoftware/mender-server/services/reporting/api/http"
32
        "github.com/mendersoftware/mender-server/services/reporting/app/reporting"
33
        dconfig "github.com/mendersoftware/mender-server/services/reporting/config"
34
        "github.com/mendersoftware/mender-server/services/reporting/store"
35
)
36

37
func init() {
×
38
        if mode := os.Getenv(gin.EnvGinMode); mode != "" {
×
39
                gin.SetMode(mode)
×
40
        } else {
×
41
                gin.SetMode(gin.ReleaseMode)
×
42
        }
×
43
}
44

45
// InitAndRun initializes the server and runs it
46
func InitAndRun(conf config.Reader, store store.Store, ds store.DataStore) error {
×
47
        ctx := context.Background()
×
48

×
49
        l := log.FromContext(ctx)
×
50

×
51
        reporting := reporting.NewApp(store, ds)
×
52

×
53
        var listen = conf.GetString(dconfig.SettingListen)
×
54
        var router = api.NewRouter(reporting)
×
55
        srv := &http.Server{
×
56
                Addr:    listen,
×
57
                Handler: router,
×
58
        }
×
59

×
60
        go func() {
×
61
                if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
×
62
                        l.Fatalf("listen: %s\n", err)
×
63
                }
×
64
        }()
65

66
        quit := make(chan os.Signal, 1)
×
67
        signal.Notify(quit, unix.SIGINT, unix.SIGTERM)
×
68
        <-quit
×
69

×
70
        l.Info("Shutdown Server ...")
×
71

×
72
        ctxWithTimeout, cancel := context.WithTimeout(ctx, 5*time.Second)
×
73
        defer cancel()
×
74
        if err := srv.Shutdown(ctxWithTimeout); err != nil {
×
75
                l.Fatal("Server Shutdown: ", err)
×
76
        }
×
77

UNCOV
78
        return nil
×
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc