Added documentation for server timeouts.

You can now disable server timeouts o.O
Added a slightly more sophisticated WS Backoff algorithm.
This commit is contained in:
Azareal 2019-03-17 09:14:47 +10:00
parent 526ba8dc0e
commit 3320cb4697
3 changed files with 26 additions and 4 deletions

View File

@ -84,6 +84,14 @@ MaxTopicTitleLength - The maximum length that a topic can be. Please note that t
MaxUsernameLength - The maximum length that a user's name can be. Please note that this measures the number of bytes and may differ from language to language with it being equal to a letter in English and being two bytes in others. MaxUsernameLength - The maximum length that a user's name can be. Please note that this measures the number of bytes and may differ from language to language with it being equal to a letter in English and being two bytes in others.
ReadTimeout - The number of seconds that we are allowed to take to fully read a request. Defaults to 5.
WriteTimeout - The number of seconds that a route is allowed to run for before the request is automatically terminated. Defaults to 10.
IdleTimeout - The number of seconds that a Keep-Alive connection will be kept open before being closed. You might to tweak this, if you use Cloudflare or similar. Defaults to 120.
Related: https://support.cloudflare.com/hc/en-us/articles/212794707-General-Best-Practices-for-Load-Balancing-at-your-origin-with-Cloudflare
# Database # Database
@ -117,6 +125,6 @@ DebugMode - Outputs a basic level of information about what Gosora is doing to h
SuperDebug - Outputs a detailed level of information about what Gosora is doing to help ease debugging. Warning: This may cause severe slowdowns in Gosora. SuperDebug - Outputs a detailed level of information about what Gosora is doing to help ease debugging. Warning: This may cause severe slowdowns in Gosora.
TemplateDebug - Output a detailed level of information about what Gosora is doing during the template transpilation step. Warning: Huge amounts of information will be dumped into the logs. TemplateDebug - Output a detailed level of information about what Gosora is doing during the template transpilation step. Warning: Large amounts of information will be dumped into the logs.
NoFsnotify - Whether you want to disable the file watcher which automatically reloads assets whenever they change. NoFsnotify - Whether you want to disable the file watcher which automatically reloads assets whenever they change.

View File

@ -473,14 +473,20 @@ func startServer() {
rtime := common.Config.ReadTimeout rtime := common.Config.ReadTimeout
if rtime == 0 { if rtime == 0 {
rtime = 5 rtime = 5
} else if rtime == -1 {
rtime = 0
} }
wtime := common.Config.WriteTimeout wtime := common.Config.WriteTimeout
if wtime == 0 { if wtime == 0 {
wtime = 10 wtime = 10
} else if wtime == -1 {
wtime = 0
} }
itime := common.Config.IdleTimeout itime := common.Config.IdleTimeout
if itime == 0 { if itime == 0 {
itime = 120 itime = 120
} else if itime == -1 {
itime = 0
} }
return &http.Server{ return &http.Server{
Addr: addr, Addr: addr,

View File

@ -8,7 +8,7 @@ var conn = false;
var selectedTopics = []; var selectedTopics = [];
var attachItemCallback = function(){} var attachItemCallback = function(){}
var baseTitle = document.title; var baseTitle = document.title;
var wsBackoff = false; var wsBackoff = 0;
// Topic move // Topic move
var forumToMoveTo = 0; var forumToMoveTo = 0;
@ -214,8 +214,11 @@ function runWebSockets() {
conn = false; conn = false;
console.log("The WebSockets connection was closed"); console.log("The WebSockets connection was closed");
let backoff = 1000; let backoff = 1000;
if(wsBackoff) backoff = 8000; if(wsBackoff < 0) wsBackoff = 0;
wsBackoff = true; else if(wsBackoff > 12) backoff = 13000;
else if(wsBackoff > 5) backoff = 7000;
wsBackoff++;
setTimeout(() => { setTimeout(() => {
var alertMenuList = document.getElementsByClassName("menu_alerts"); var alertMenuList = document.getElementsByClassName("menu_alerts");
for(var i = 0; i < alertMenuList.length; i++) { for(var i = 0; i < alertMenuList.length; i++) {
@ -223,6 +226,11 @@ function runWebSockets() {
} }
runWebSockets(); runWebSockets();
}, 60 * backoff); }, 60 * backoff);
if(wsBackoff > 0) {
if(wsBackoff <= 5) setTimeout(() => wsBackoff--, 60 * 4000);
else if(wsBackoff <= 12) setTimeout(() => wsBackoff--, 60 * 20000);
}
} }
conn.onmessage = (event) => { conn.onmessage = (event) => {