Fossil SCM

Improve the message shown on a server over-load condition by including the URL that encountered the overload and the timestamp for when the overload occurred.

drh 2025-04-14 13:53 trunk
Commit 278507e871158488103a7aade9e4f5dbbf263343a2643f23d053badc9a345a5b
1 file changed +21 -8
+21 -8
--- src/loadctrl.c
+++ src/loadctrl.c
@@ -43,10 +43,30 @@
4343
** Print the load average on the host machine.
4444
*/
4545
void loadavg_test_cmd(void){
4646
fossil_print("load-average: %f\n", load_average());
4747
}
48
+
49
+/*
50
+** WEBPAGE: test-overload
51
+**
52
+** Generate the response that would normally be shown only when
53
+** service is denied due to an overload condition. This is for
54
+** testing of the overload warning page.
55
+*/
56
+void overload_page(void){
57
+ double mxLoad = atof(db_get("max-loadavg", "0.0"));
58
+ style_set_current_feature("test");
59
+ style_header("Server Overload");
60
+ @ <h2>The server load is currently too high.
61
+ @ Please try again later.</h2>
62
+ @ <p>Current load average: %f(load_average())<br>
63
+ @ Load average limit: %f(mxLoad)<br>
64
+ @ URL: %h(g.zBaseURL)%h(P("PATH_INFO"))<br>
65
+ @ Timestamp: %h(db_text("","SELECT datetime()"))Z</p>
66
+ style_finish_page();
67
+}
4868
4969
/*
5070
** Abort the current page request if the load average of the host
5171
** computer is too high. Admin and Setup users are exempt from this
5272
** restriction.
@@ -60,17 +80,10 @@
6080
login_check_credentials();
6181
if(g.perm.Admin || g.perm.Setup){
6282
return;
6383
}
6484
#endif
65
-
66
- style_set_current_feature("test");
67
- style_header("Server Overload");
68
- @ <h2>The server load is currently too high.
69
- @ Please try again later.</h2>
70
- @ <p>Current load average: %f(load_average()).<br>
71
- @ Load average limit: %f(mxLoad)</p>
72
- style_finish_page();
85
+ overload_page();
7386
cgi_set_status(503,"Server Overload");
7487
cgi_reply();
7588
exit(0);
7689
}
7790
--- src/loadctrl.c
+++ src/loadctrl.c
@@ -43,10 +43,30 @@
43 ** Print the load average on the host machine.
44 */
45 void loadavg_test_cmd(void){
46 fossil_print("load-average: %f\n", load_average());
47 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
49 /*
50 ** Abort the current page request if the load average of the host
51 ** computer is too high. Admin and Setup users are exempt from this
52 ** restriction.
@@ -60,17 +80,10 @@
60 login_check_credentials();
61 if(g.perm.Admin || g.perm.Setup){
62 return;
63 }
64 #endif
65
66 style_set_current_feature("test");
67 style_header("Server Overload");
68 @ <h2>The server load is currently too high.
69 @ Please try again later.</h2>
70 @ <p>Current load average: %f(load_average()).<br>
71 @ Load average limit: %f(mxLoad)</p>
72 style_finish_page();
73 cgi_set_status(503,"Server Overload");
74 cgi_reply();
75 exit(0);
76 }
77
--- src/loadctrl.c
+++ src/loadctrl.c
@@ -43,10 +43,30 @@
43 ** Print the load average on the host machine.
44 */
45 void loadavg_test_cmd(void){
46 fossil_print("load-average: %f\n", load_average());
47 }
48
49 /*
50 ** WEBPAGE: test-overload
51 **
52 ** Generate the response that would normally be shown only when
53 ** service is denied due to an overload condition. This is for
54 ** testing of the overload warning page.
55 */
56 void overload_page(void){
57 double mxLoad = atof(db_get("max-loadavg", "0.0"));
58 style_set_current_feature("test");
59 style_header("Server Overload");
60 @ <h2>The server load is currently too high.
61 @ Please try again later.</h2>
62 @ <p>Current load average: %f(load_average())<br>
63 @ Load average limit: %f(mxLoad)<br>
64 @ URL: %h(g.zBaseURL)%h(P("PATH_INFO"))<br>
65 @ Timestamp: %h(db_text("","SELECT datetime()"))Z</p>
66 style_finish_page();
67 }
68
69 /*
70 ** Abort the current page request if the load average of the host
71 ** computer is too high. Admin and Setup users are exempt from this
72 ** restriction.
@@ -60,17 +80,10 @@
80 login_check_credentials();
81 if(g.perm.Admin || g.perm.Setup){
82 return;
83 }
84 #endif
85 overload_page();
 
 
 
 
 
 
 
86 cgi_set_status(503,"Server Overload");
87 cgi_reply();
88 exit(0);
89 }
90

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button