Skip to content

Commit

Permalink
Turn more hardcoded time values into ini settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Apr 6, 2012
1 parent 0cb1989 commit 0e46d84
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
22 changes: 19 additions & 3 deletions config/testswarm-sample.ini
Expand Up @@ -88,9 +88,25 @@ password = "root"
; this number of seconds before trying again.

;timeout_rate = 180
; The maximum amount of time in seconds a run may be silent before it is
; considered broken. After this the run will be cancelled and run saved to
; TestSwarm (saverun) with a time-out status.
; Number of seconds a run may take to run.
; After this time the run-iframe will be cancelled and a timeout-report
; is submitted to action=saverun instead.

;run_savereq_timeout = 10
; Number of seconds the AJAX request to action=saverun on RunPage may take
; until it is aborted.

;run_saveretry_max = 4
; If the AJAX request to action=saverun on RunPage fails entirely (e.g.
; times out, 404 Not Found, 500 Internal Server Error, ..) it will retry
; up to this number of times before reaching out to the last resort (restarting
; the browser window). When in doubt, keep a higher rather than a lower value.
; Because it's better to have a client in a still-alive page retrying a few
; times until the server is back on, then refreshing too soon when the RunPage
; doesn't even render (which effectively permanently disconnects the client).

;run_saveretry_sleep = 15
; Number of seconds to wait between retries for action=saverun.

;refresh_control = 0
; Increasing this number will force all connected clients to refresh the
Expand Down
6 changes: 6 additions & 0 deletions inc/init.php
Expand Up @@ -65,6 +65,9 @@
"cooldown_rate" => "15",
"update_rate" => "30",
"timeout_rate" => "180",
"run_savereq_timeout" => "10",
"run_saveretry_max" => "4",
"run_saveretry_sleep" => "15",
"refresh_control" => "0",
),
"storage" => array(
Expand Down Expand Up @@ -96,6 +99,9 @@
$swarmConfig["client"]["cooldown_rate"] = intval( $swarmConfig["client"]["cooldown_rate"] );
$swarmConfig["client"]["update_rate"] = intval( $swarmConfig["client"]["update_rate"] );
$swarmConfig["client"]["timeout_rate"] = intval( $swarmConfig["client"]["timeout_rate"] );
$swarmConfig["client"]["run_savereq_timeout"] = intval( $swarmConfig["client"]["run_savereq_timeout"] );
$swarmConfig["client"]["run_saveretry_max"] = intval( $swarmConfig["client"]["run_saveretry_max"] );
$swarmConfig["client"]["run_saveretry_sleep"] = intval( $swarmConfig["client"]["run_saveretry_sleep"] );
$swarmConfig["client"]["refresh_control"] = intval( $swarmConfig["client"]["refresh_control"] );

$swarmConfig["web"]["ajax_update_interval"] = intval( $swarmConfig["web"]["ajax_update_interval"] );
Expand Down
8 changes: 4 additions & 4 deletions js/run.js
Expand Up @@ -24,7 +24,7 @@
* Softly validate the SWARM object
*/
if ( !SWARM.client_id || !SWARM.conf ) {
$( function() {
$( function () {
msg( "Error: No client id configured! Aborting." );
});
return;
Expand All @@ -41,7 +41,7 @@
$.ajax({
type: "POST",
url: SWARM.conf.web.contextpath + "api.php",
timeout: 10000,
timeout: SWARM.conf.client.run_savereq_timeout * 1000,
cache: false,
data: query,
dataType: "json",
Expand All @@ -50,12 +50,12 @@
ok.apply( this, arguments );
},
error: function () {
if ( errorOut > 4 ) {
if ( errorOut > SWARM.conf.client.run_saveretry_max ) {
cmds.reload();
} else {
errorOut += 1;
msg( "Error connecting to server, retrying..." );
setTimeout( retry, 15000 );
setTimeout( retry, SWARM.conf.client.run_saveretry_sleep * 1000 );
}
}
});
Expand Down

0 comments on commit 0e46d84

Please sign in to comment.