Jump to content

[SOLVED] Pinpointing the source of 503 error


Masteries

Recommended Posts

I've experienced two 503 "service unavailable" errors within the span of 3 days. When the error occurs, the backoffice is still functional but the whole frontoffice (homepage etc) shows this error. The first time it happened was 3 days ago, I solved this by restarting the PHP process. The 2nd time happened today. I will provide some information as to what I've been doing these past 2 weeks to help analyze the source of the problem:

 

- Added a custom text field to the contact form following Nemo's tutorial (without using overrides). Aside from the database table, changes were made to CustomerThread.php, ContactController.php and contact-form.tpl.

 

- I've been making minor changes to some other .tpl files and .css files (such as footer.tpl, global.css and etc). During this I frequently kept switching the cache settings from "Never compile template files" to "Recompile if the files have been updated" to see the .css/.tpl changes. I usually have it set to "Never compile template files" as it generates way too many cache files. Would this perhaps be the cause because it overloads the server/memory?

 

- I've added a custom payment module which is a copy from the bankwire module. At first I was having a trouble installing the module, it generated an error related to Tools::recurseCopy everytime I tried to install it (I wasn't aware my Prestashop version didn't have that function). Anyhow I checked Tools.php and saw that there was instead a "copy" function so I changed the "recurseCopy" line to "Tools::copy" instead and the module installed without any errors. Little did I know that the "copy" function is not at all the right one for the job. Anyhow, I thought the 503 error was generated because of this change I made so I removed the module along with all of its content. However, today the 503 error popped up again and I fixed it quickly by restarting the PHP process once more. I still believe that the "copy" function I used instead of "recurseCopy" created some sort of an endless loop of file copying or something of that sort (although I don't see any copy files in the directory specified). This was the line I changed in the module:

Tools::recurseCopy(dirname(__FILE__).'/mails',_PS_MAIL_DIR_);

to:

 Tools::copy(dirname(__FILE__).'/mails',_PS_MAIL_DIR_);

This is the "copy" function which was in Tools.php:

 

  public static function copy($source, $destination, $stream_context = null)
    {
        if (is_null($stream_context) && !preg_match('/^https?:\/\//', $source)) {
            return @copy($source, $destination);
        }
        return @file_put_contents($destination, Tools::file_get_contents($source, false, $stream_context));
    }

Which one of these could be the cause for the 503 errors? Or perhaps is there a different factor causing the 503 errors? Could it be related to my host (although I've never had this error before)? Any help would be deeply appreciated!

Edited by Masteries (see edit history)
Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...

How did you solve this? By simply setting your Smarty caching option to ''never compile..." ?

Thank you.

 

Sorry for the 2 months late response. I will address this so others who are experiencing the same problem can also get a closure. The reason I was having the error was most likely caused by the constant tampering with cache options (turning it on and off to see changes made in template files). This caused heavy load on the server as having to compile every time I turned on the cache does that. I have weak server specs so this could also be solved by upgrading your server. At least that's what I think was causing the issue. I've completely turned off caching for now except for CCC and I never experienced the issue again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...