The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation


Q&A: My Google Drive keeps Disappearing. Help!

TITLE
  Hi, Core Technologies support team.

AlwaysUp has been invaluable to our business, which is why I’ve bought several copies for different machines.

Recently I started running into a problem on my production PC. I searched for a bit through your FAQs and blogs but didn’t see this particular problem. Maybe you have a quick workaround?

I’ve set up Google Drive for desktop to run as a service. An application on that production PC depends on the G: drive being present.

But sometimes the G: drive disappears after a while, even though AlwaysUp shows Google Drive running.

When that happens, my application goes haywire. Eventually, I’ll have to debug to keep the app from crashing when the G drive is not available, but in the meantime, do you have an answer for what’s happening?

I will appreciate any help you can provide.

— Randy

Hi Randy, thanks for reaching out to report the problem. No one on our team has seen Google Drive failing as you described so we can’t say precisely what going on, sorry.

But we can offer a couple of solutions that should (1) lessen the occurrence of the problem and (2) quickly restore functionality when the problem arises.

Solution #1: Have AlwaysUp restart Google Drive every night

If Drive breaks after it’s been running for some time, the program may have a resource leak.

Perhaps Drive isn’t freeing all the RAM it’s requested. Or it may be holding on to a network port for too long. Or it could be something else. It’s difficult to pinpoint the issue because we don’t have access to the source code (or to decent log files, for that matter).

For mysterious situations like this, we recommend introducing a nightly restart. That is, you should have AlwaysUp automatically restart Google Drive at a set time when no one is likely to be using it.

The theory is that restarting Google Drive will clear out any resource leaks. Afterwards, the program will come up “fresh” and ready to do its work — at least for the next few hours.

To restart Drive nightly:

  1. Edit Google Drive in AlwaysUp (select Application > Edit/View “Google Drive for desktop” from the menu).

  2. In the Edit/View Application window that comes up, switch to the Monitor tab.

  3. Check the Every box, select Day from the drop-down and choose a convenient time to restart Google Drive. 2 AM works for us:

    Restart Google Drive every night at 2 AM
  4. Save your changes.

With that setting in place, AlwaysUp will restart Drive every night at 2 AM. And as a result, no instance of Drive will run for longer than a day. If we’re lucky, no resource leak will grow fast enough to cripple Drive within those 24 hours.

But if we’re not dealing with a resource leak and Drive can stop working at any time, a nightly restart won’t help much. Fortunately, the next solution tackles the problem more directly.

Solution #2: Install a sanity check to detect the failure and automatically restart Google Drive

We built AlwaysUp to handle a range of failures while running an application. For example, AlwaysUp can detect and automatically recycle programs that:

  • Use too much memory;

  • Run wild with the CPU;

  • Get stuck at a crash window;

  • Become unresponsive to input.

For those cases, you simply specify the restrictions (e.g. the maximum RAM to use) and AlwaysUp will deal with any violations on your behalf.

But none of those built-in capabilities will help with your Google Drive problem. When Drive fails, it’s not related to CPU, RAM or any of the metrics that AlwaysUp tracks. It’s about knowing when your G drive isn’t mapped.

To handle non-standard failures like yours, we must rely on AlwaysUp’s Sanity Check feature. We’ll write a batch file that detects when the G drive isn’t mapped and then show you how to plug that into AlwaysUp.

Download our sanity check to detect when your G drive isn’t available

Here is the batch file we developed for your situation:

@echo off
:: This batch file checks if a drive letter is mapped or not.
:: It exits with 0 if the drive is mapped and 1 if it isn't.
SET gdrive=G
if exist %gdrive%:\ (
    	echo The %gdrive% drive is mapped Exiting with 0 to continue running.
	exit /b 0
)
echo The %gdrive% drive is NOT mapped. Exiting with 1 to restart.
exit /b 1

As you can see, it simply checks if the G:\ folder exists and returns:

  • 0 if G:\ is accessible

  • 1 if G:\ cannot be accessed

Please download the script and save it in a known location on your computer running Google Drive. We’ll use it in the next step.

Plug the sanity check into AlwaysUp

Since we have a batch file to detect the problem, let’s tell AlwaysUp how to use it:

  1. Edit Google Drive in AlwaysUp (select Application > Edit/View “Google Drive for desktop” from the menu).

  2. In the Edit/View Application window that comes up, switch to the Monitor tab.

  3. Check the Whenever it fails a “sanity check” box and click the button:

    Install the sanity check
  4. In the Configure Sanity Check window that comes up, enter the full path to the batch file in the Run field and specify how often to perform the sanity check. Every 5 minutes should be enough so that’s what we entered:

    Configure the Google Drive sanity check
  5. Save your changes.

And with that sanity check in place, AlwaysUp will run the batch file every 5 minutes. If the batch file returns 0, indicating that the G drive is available, nothing will happen. AlwaysUp will continue to babysit Google Drive (and schedule the next check for 5 minutes later).

But if the batch file returns 1 — because it couldn’t access the G drive — AlwaysUp will promptly shut down Google Drive and start a new copy. Doing so should restore access to the G drive.

Happy Google Driving!

Posted in AlwaysUp | Tagged , , , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *