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.
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
@ -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.
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.

View File

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

View File

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