Преглед на файлове

Merge remote-tracking branch 'origin/stable' into v2

tags/v2.2.3
9seconds преди 1 месец
родител
ревизия
7fec30908a
променени са 7 файла, в които са добавени 136 реда и са изтрити 2 реда
  1. 3
    0
      .gitattributes
  2. 81
    2
      .goreleaser.yml
  3. 1
    0
      README.md
  4. Двоични данни
      default.pgo
  5. 17
    0
      main.go
  6. 7
    0
      run_profile.go
  7. 27
    0
      run_profile_tag_prof.go

+ 3
- 0
.gitattributes Целия файл

@@ -0,0 +1,3 @@
1
+# git config merge.theirs.name "Always accept theirs"
2
+# git config merge.theirs.driver "cp %B %A"
3
+default.pgo binary merge=theirs

+ 81
- 2
.goreleaser.yml Целия файл

@@ -10,13 +10,15 @@ before:
10 10
     - go generate ./...
11 11
 
12 12
 builds:
13
-  - binary: '{{ .ProjectName }}'
13
+  - id: default
14
+    binary: '{{ .ProjectName }}'
14 15
     goos:
15 16
       - darwin
16 17
       - freebsd
17 18
       - linux
18 19
       - netbsd
19 20
       - openbsd
21
+      - windows
20 22
     goarch:
21 23
       - 386
22 24
       - amd64
@@ -34,15 +36,92 @@ builds:
34 36
     ignore:
35 37
       - goos: darwin
36 38
         goarch: 386
39
+      - goos: darwin
40
+        goarch: arm
37 41
       - goos: freebsd
38 42
         goarch: arm64
39 43
       - goos: netbsd
40 44
         goarch: arm64
41 45
       - goos: openbsd
42 46
         goarch: arm64
47
+      - goos: windows
48
+        goarch: 386
49
+      - goos: windows
50
+        goarch: arm
51
+  - id: mips
52
+    binary: '{{ .ProjectName }}'
53
+    goos:
54
+      - linux
55
+    goarch:
56
+      - mips
57
+      - mipsle
58
+    gomips:
59
+      - softfloat
60
+    env:
61
+      - CGO_ENABLED=0
62
+    flags:
63
+      - -trimpath
64
+      - -mod=readonly
65
+    ldflags: -s -w -X main.version={{ .Version }}
66
+  - id: arm64-v9
67
+    binary: '{{ .ProjectName }}'
68
+    goos:
69
+      - darwin
70
+      - linux
71
+    goarch:
72
+      - arm64
73
+    goarm64:
74
+      - v9.0
75
+    env:
76
+      - CGO_ENABLED=0
77
+    flags:
78
+      - -trimpath
79
+      - -mod=readonly
80
+    ldflags: -s -w -X main.version={{ .Version }}
81
+  - id: amd64-v3
82
+    binary: '{{ .ProjectName }}'
83
+    goos:
84
+      - darwin
85
+      - freebsd
86
+      - linux
87
+      - netbsd
88
+      - openbsd
89
+      - windows
90
+    goarch:
91
+      - amd64
92
+    goamd64:
93
+      - v3
94
+    env:
95
+      - CGO_ENABLED=0
96
+    flags:
97
+      - -trimpath
98
+      - -mod=readonly
99
+    ldflags: -s -w -X main.version={{ .Version }}
43 100
 
44 101
 archives:
45
-  - name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
102
+  - id: default
103
+    ids:
104
+      - default
105
+      - mips
106
+    name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
107
+    formats:
108
+      - tar.gz
109
+    wrap_in_directory: true
110
+    format_overrides:
111
+      - goos: windows
112
+        formats:
113
+          - zip
114
+    files:
115
+      - LICENSE
116
+      - README.md
117
+      - SECURITY.md
118
+      - BEST_PRACTICES.md
119
+      - example.config.toml
120
+  - id: optimized
121
+    ids:
122
+      - arm64-v9
123
+      - amd64-v3
124
+    name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm64 }}-{{ .Arm64 }}{{ end }}{{ if .Amd64 }}-{{ .Amd64 }}{{ end }}'
46 125
     formats:
47 126
       - tar.gz
48 127
     wrap_in_directory: true

+ 1
- 0
README.md Целия файл

@@ -380,6 +380,7 @@ ExecStart=/usr/local/bin/mtg run /etc/mtg.toml
380 380
 Restart=always
381 381
 RestartSec=3
382 382
 DynamicUser=true
383
+LimitNOFILE=65536
383 384
 AmbientCapabilities=CAP_NET_BIND_SERVICE
384 385
 
385 386
 [Install]

Двоични данни
default.pgo Целия файл


+ 17
- 0
main.go Целия файл

@@ -14,6 +14,23 @@ import (
14 14
 )
15 15
 
16 16
 func main() {
17
+	// this runs profiling server. To enable it, build with prof tag
18
+	//   $ go build -tags prof
19
+	//
20
+	// Then you can pass a port using MTG_PROF_PORT environment variable.
21
+	// Default is 6000
22
+	//   $ MTG_PROF_PORT=6000 mtg run config.toml
23
+	//
24
+	// It will run a webserver with profiling data on
25
+	// localhost:${MTG_PROF_PORT:-6000}.
26
+	//
27
+	// To collect PGO do following:
28
+	//   $ curl -o default.pgo 'http://localhost:6000/debug/pprof/profile?seconds=300'
29
+	//
30
+	// See also https://pkg.go.dev/net/http/pprof
31
+	//          https://go.dev/blog/pprof
32
+	runProfile()
33
+
17 34
 	cli := &cli.CLI{}
18 35
 	ctx := kong.Parse(cli, kong.Vars{
19 36
 		"version": getVersion(),

+ 7
- 0
run_profile.go Целия файл

@@ -0,0 +1,7 @@
1
+//go:build !prof
2
+
3
+package main
4
+
5
+func runProfile() {
6
+
7
+}

+ 27
- 0
run_profile_tag_prof.go Целия файл

@@ -0,0 +1,27 @@
1
+//go:build prof
2
+
3
+package main
4
+
5
+import (
6
+	"fmt"
7
+	"net"
8
+	"net/http"
9
+	_ "net/http/pprof" //nolint: gosec
10
+	"os"
11
+)
12
+
13
+const DefaultProfPort = "6000"
14
+
15
+func runProfile() {
16
+	port := os.Getenv("MTG_PROF_PORT")
17
+	if port == "" {
18
+		port = DefaultProfPort
19
+	}
20
+
21
+	listener, err := net.Listen("tcp", net.JoinHostPort("127.0.0.1", port))
22
+	if err != nil {
23
+		panic(err)
24
+	}
25
+
26
+	go http.Serve(listener, nil)
27
+}

Loading…
Отказ
Запис