This repository was archived by the owner on Jul 7, 2024. It is now read-only.
File tree 3 files changed +19
-6
lines changed
3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ After=network.target network-online.target
5
5
[Service]
6
6
User =qrystal-cs
7
7
ExecStart =qrystal-cs -config /etc/qrystal/cs-config.yml
8
- Environment =QRYSTAL_PROFILE_PATH =/tmp/qrystal-profile.pprof
8
+ Environment =QRYSTAL_PROFILE =on
9
9
RuntimeDirectory =qrystal-cs
10
10
RuntimeDirectoryMode =0700
11
11
StateDirectory =qrystal-cs
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ After=network.target network-online.target
4
4
5
5
[Service]
6
6
ExecStart =qrystal-runner
7
- Environment =QRYSTAL_PROFILE_PATH =/tmp/qrystal-profile.pprof
7
+ Environment =QRYSTAL_PROFILE =on
8
8
Environment =RUNNER_MIO_PATH =/opt/qrystal/runner-mio
9
9
Environment =RUNNER_NODE_PATH =/opt/qrystal/runner-node
10
10
Environment =RUNNER_NODE_CONFIG_PATH =/etc/qrystal/node-config.yml
Original file line number Diff line number Diff line change @@ -5,17 +5,30 @@ import (
5
5
"os"
6
6
"runtime/pprof"
7
7
"time"
8
+
9
+ "github.com/nyiyui/qrystal/util"
8
10
)
9
11
10
12
func Profile () {
11
13
log .Print ("profiling is enabled" )
12
- profilePath := os .Getenv ("QRYSTAL_PROFILE_PATH " )
13
- if profilePath != " " {
14
- profile (profilePath )
14
+ enable := os .Getenv ("QRYSTAL_PROFILE " )
15
+ if enable == "on " {
16
+ profile ()
15
17
}
16
18
}
17
19
18
- func profile (profilePath string ) {
20
+ func profile () {
21
+ f , err := os .CreateTemp ("" , "qrystal-profile-*" )
22
+ if err != nil {
23
+ util .S .Errorf ("create temp: %s" , err )
24
+ return
25
+ }
26
+ profilePath := f .Name ()
27
+ err = f .Close ()
28
+ if err != nil {
29
+ util .S .Errorf ("close temp: %s" , err )
30
+ return
31
+ }
19
32
writeProfile (profilePath )
20
33
ticker := time .NewTicker (1 * time .Hour )
21
34
go func () {
You can’t perform that action at this time.
0 commit comments