File tree Expand file tree Collapse file tree 3 files changed +26
-32
lines changed Expand file tree Collapse file tree 3 files changed +26
-32
lines changed Original file line number Diff line number Diff line change @@ -293,34 +293,17 @@ jobs:
293
293
apiToken : ${{ secrets.CF_R2_API_TOKEN }}
294
294
wranglerVersion : " 4.21.1"
295
295
command : |
296
- retry_upload() {
297
- local file_path="$1"
298
- local remote_path="$2"
299
- local max_attempts=3
300
- local attempt=1
301
-
302
- while [ $attempt -le $max_attempts ]; do
303
- echo "Attempt $attempt of $max_attempts: Uploading $file_path to $remote_path"
304
- if r2 object put "$remote_path" --file "$file_path" --remote; then
305
- echo "Successfully uploaded $file_path on attempt $attempt"
306
- return 0
307
- else
308
- echo "Failed to upload $file_path on attempt $attempt"
309
- if [ $attempt -lt $max_attempts ]; then
310
- echo "Waiting 5 seconds before retry..."
311
- sleep 5
312
- fi
313
- attempt=$((attempt + 1))
314
- fi
315
- done
316
-
317
- echo "Failed to upload $file_path after $max_attempts attempts"
318
- return 1
319
- }
320
-
321
- # Upload files with retry
322
- retry_upload ./${{ env.DIST }}.tar.gz nginx-ui-dev-build/${{ env.DIST }}.tar.gz
323
- retry_upload ./${{ env.DIST }}.tar.gz.digest nginx-ui-dev-build/${{ env.DIST }}.tar.gz.digest
296
+ for i in 1 2 3; do
297
+ echo "Attempt $i: Uploading ${{ env.DIST }}.tar.gz"
298
+ wrangler r2 object put nginx-ui-dev-build/${{ env.DIST }}.tar.gz --file ./${{ env.DIST }}.tar.gz --remote && break
299
+ [ $i -lt 3 ] && sleep 5
300
+ done
301
+
302
+ for i in 1 2 3; do
303
+ echo "Attempt $i: Uploading ${{ env.DIST }}.tar.gz.digest"
304
+ wrangler r2 object put nginx-ui-dev-build/${{ env.DIST }}.tar.gz.digest --file ./${{ env.DIST }}.tar.gz.digest --remote && break
305
+ [ $i -lt 3 ] && sleep 5
306
+ done
324
307
325
308
docker-build :
326
309
if : github.event_name != 'pull_request'
Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ import (
11
11
"github.com/uozi-tech/cosy/logger"
12
12
)
13
13
14
+ var (
15
+ nginxPrefix string
16
+ )
17
+
14
18
// Returns the directory containing the nginx executable
15
19
func GetNginxExeDir () string {
16
20
return filepath .Dir (getNginxSbinPath ())
@@ -32,14 +36,21 @@ func resolvePath(path string) string {
32
36
33
37
// GetPrefix returns the prefix of the nginx executable
34
38
func GetPrefix () string {
39
+ if nginxPrefix != "" {
40
+ return nginxPrefix
41
+ }
42
+
35
43
out := getNginxV ()
36
44
r , _ := regexp .Compile (`--prefix=(\S+)` )
37
45
match := r .FindStringSubmatch (out )
38
46
if len (match ) < 1 {
39
47
logger .Error ("nginx.GetPrefix len(match) < 1" )
40
- return "/usr/local/nginx"
48
+ nginxPrefix = "/usr/local/nginx"
49
+ return nginxPrefix
41
50
}
42
- return resolvePath (match [1 ])
51
+
52
+ nginxPrefix = resolvePath (match [1 ])
53
+ return nginxPrefix
43
54
}
44
55
45
56
// GetConfPath returns the path of the nginx configuration file
Original file line number Diff line number Diff line change @@ -17,18 +17,17 @@ import (
17
17
// Regular expression for log directives - matches access_log or error_log
18
18
var (
19
19
logDirectiveRegex = regexp .MustCompile (`(?m)(access_log|error_log)\s+([^\s;]+)(?:\s+[^;]+)?;` )
20
- prefix = ""
21
20
)
22
21
23
22
// Use init function to automatically register callback
24
23
func init () {
25
- prefix = nginx .GetPrefix ()
26
24
// Register the callback directly with the global registry
27
25
cache .RegisterCallback (scanForLogDirectives )
28
26
}
29
27
30
28
// scanForLogDirectives scans and parses configuration files for log directives
31
29
func scanForLogDirectives (configPath string , content []byte ) error {
30
+ prefix := nginx .GetPrefix ()
32
31
// First, remove all log paths that came from this config file
33
32
// This ensures that removed log directives are properly cleaned up
34
33
RemoveLogPathsFromConfig (configPath )
@@ -147,6 +146,7 @@ func isValidLogPath(logPath string) bool {
147
146
148
147
// IsLogPathUnderWhiteList checks if a log path is under one of the paths in LogDirWhiteList
149
148
func IsLogPathUnderWhiteList (path string ) bool {
149
+ prefix := nginx .GetPrefix ()
150
150
cacheKey := fmt .Sprintf ("isLogPathUnderWhiteList:%s" , path )
151
151
res , ok := cache .Get (cacheKey )
152
152
You can’t perform that action at this time.
0 commit comments