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.
Commit
278507e871158488103a7aade9e4f5dbbf263343a2643f23d053badc9a345a5b
Parent
aac885a61981dfd…
1 file changed
+21
-8
+21
-8
| --- src/loadctrl.c | ||
| +++ src/loadctrl.c | ||
| @@ -43,10 +43,30 @@ | ||
| 43 | 43 | ** Print the load average on the host machine. |
| 44 | 44 | */ |
| 45 | 45 | void loadavg_test_cmd(void){ |
| 46 | 46 | fossil_print("load-average: %f\n", load_average()); |
| 47 | 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 | +} | |
| 48 | 68 | |
| 49 | 69 | /* |
| 50 | 70 | ** Abort the current page request if the load average of the host |
| 51 | 71 | ** computer is too high. Admin and Setup users are exempt from this |
| 52 | 72 | ** restriction. |
| @@ -60,17 +80,10 @@ | ||
| 60 | 80 | login_check_credentials(); |
| 61 | 81 | if(g.perm.Admin || g.perm.Setup){ |
| 62 | 82 | return; |
| 63 | 83 | } |
| 64 | 84 | #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(); | |
| 73 | 86 | cgi_set_status(503,"Server Overload"); |
| 74 | 87 | cgi_reply(); |
| 75 | 88 | exit(0); |
| 76 | 89 | } |
| 77 | 90 |
| --- 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 |