Просмотр исходного кода

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

tags/v2.2.3
9seconds 1 месяц назад
Родитель
Сommit
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 Просмотреть файл

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
     - go generate ./...
10
     - go generate ./...
11
 
11
 
12
 builds:
12
 builds:
13
-  - binary: '{{ .ProjectName }}'
13
+  - id: default
14
+    binary: '{{ .ProjectName }}'
14
     goos:
15
     goos:
15
       - darwin
16
       - darwin
16
       - freebsd
17
       - freebsd
17
       - linux
18
       - linux
18
       - netbsd
19
       - netbsd
19
       - openbsd
20
       - openbsd
21
+      - windows
20
     goarch:
22
     goarch:
21
       - 386
23
       - 386
22
       - amd64
24
       - amd64
34
     ignore:
36
     ignore:
35
       - goos: darwin
37
       - goos: darwin
36
         goarch: 386
38
         goarch: 386
39
+      - goos: darwin
40
+        goarch: arm
37
       - goos: freebsd
41
       - goos: freebsd
38
         goarch: arm64
42
         goarch: arm64
39
       - goos: netbsd
43
       - goos: netbsd
40
         goarch: arm64
44
         goarch: arm64
41
       - goos: openbsd
45
       - goos: openbsd
42
         goarch: arm64
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
 archives:
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
     formats:
125
     formats:
47
       - tar.gz
126
       - tar.gz
48
     wrap_in_directory: true
127
     wrap_in_directory: true

+ 1
- 0
README.md Просмотреть файл

380
 Restart=always
380
 Restart=always
381
 RestartSec=3
381
 RestartSec=3
382
 DynamicUser=true
382
 DynamicUser=true
383
+LimitNOFILE=65536
383
 AmbientCapabilities=CAP_NET_BIND_SERVICE
384
 AmbientCapabilities=CAP_NET_BIND_SERVICE
384
 
385
 
385
 [Install]
386
 [Install]

Двоичные данные
default.pgo Просмотреть файл


+ 17
- 0
main.go Просмотреть файл

14
 )
14
 )
15
 
15
 
16
 func main() {
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
 	cli := &cli.CLI{}
34
 	cli := &cli.CLI{}
18
 	ctx := kong.Parse(cli, kong.Vars{
35
 	ctx := kong.Parse(cli, kong.Vars{
19
 		"version": getVersion(),
36
 		"version": getVersion(),

+ 7
- 0
run_profile.go Просмотреть файл

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

+ 27
- 0
run_profile_tag_prof.go Просмотреть файл

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
+}

Загрузка…
Отмена
Сохранить