Database Read Only Mode and Login Functions

5 posts by 3 authors in: Forums > CMS Builder
Last Post: January 11, 2017   (RSS)

By ross - January 10, 2017

Hi Steve

Thanks for posting.

I'll check with the rest of the team on this to see what options we have and get back to you.

Let me know any other questions in the meantime.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By Dave - January 11, 2017

Hey Steve, 

Is it just the database, or the whole filesystem?  If it's the filesystem too you could just use the PHP is_writable() function to check a file: 
http://php.net/manual/en/function.is-writable.php

Generally, what you might want to do is just show a temporary page indicating the server is temporarily unavailable.  Because there's likely going to be lots of things that require write access to the db/filesystem.  

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By Steve99 - January 11, 2017

Hey Dave,

It was only the database -- and it's extremely rare... just happened to get a call from the client during the 5 minute read-only incident (figures they were reviewing things with a prospective customer at the time...). Yes, there are various things requiring write access to db and filesystem. And yes, I am in total agreement with you on the "temporarily unavailable" page.

The collective thought of everyone here at the office was "well, these things can happen - just sit tight and services will be fully restored...".

As the rest of the website stays operational (since data can still be accessed in read-only mode), the question arose from our client asking about accessing Website Membership content in a "view only" fashion --  hence the post.

Thanks,
Steve

By Dave - January 11, 2017

Hi Steve, 

It might be more hassle then it's worth to pursue.  But you could try something like this: 

$isReadOnly = mysql_get_query("SELECT @@GLOBAL.read_only", true)[0];
if ($isReadOnly) {
  header('HTTP/1.1 503 Service Temporarily Unavailable');
  header('Status: 503 Service Temporarily Unavailable');
  header('Retry-After: 7200'); // in seconds
  print "Server is currently unavailable, please try back later!";
  exit;
}

Or just hide the errors Website Membership returns with @.  I think all it updates is the last login date and that's not critical in most cases.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com