diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 045807b18..62fc03a29 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -14,6 +14,7 @@ date. - fix: 7.4 Editing SQL Form seems to break site ...? - rfe: Export & files + - Added master failover database config option. - URLs that would have been created like page.html/article.html are now created like page/article.html to make them look more realistic. - fix: Fixing bad link on the Event page to the search engine. Added a new diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 18458cd93..1d2388424 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -146,6 +146,19 @@ # "pass" : "password" # }, +# You can configure a backup master database as a failover in case +# your primary database goes down. WebGUI will use this database until +# the original becomes available. However, this does nothing to change +# the settings of your database. If it was set up as a slave until the +# master went down, then some script will have to be written to convert +# it from a slave to a master. + +# "failoverdb" : { +# "dsn" : "DBI:mysql:www_example_com;host=failover.example.com;port=3306", +# "user" : "webgui", +# "password" : "password" +# }, + # Set this value if you wish to override all outbound emails to a specific # user for testing purposes. diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 8d006e1db..00d76c023 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -173,6 +173,11 @@ sub db { my $skipFatal = shift; unless (exists $self->{_db}) { my $db = WebGUI::SQL->connect($self,$self->config->get("dsn"), $self->config->get("dbuser"), $self->config->get("dbpass")); + if (!defined $db && defined $self->config->get("failoverdb")) { + $self->errorHandler->warn("Main DB down, resorting to using failover."); + my $failover = $self->config->get("failoverdb"); + $db = WebGUI::SQL->connect($self,$failover->{dsn}, $failover->{user}, $failover->{password}); + } if (defined $db) { $self->{_db} = $db; }