We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27072
    • 76 Posts
    Hello all.

    I am performing 50 calls to the server (same function with different parameters) for heavy duty database operation - generating Google sitemaps for almost one million documents (celebrity pages).

    Each call requires about 8 seconds execution time.

    I also wish to keep the business logic (script) in the MODx framework versus an independent PHP script file that is run from the command line or a cron job/windows scheduler.

    The problem is that however I run the procedure from MODx, such as calling a snippet or running a module - the execution time is measure from when the client browser made the first call, and until the run is finished. That results in execution timeout errors.

    I obviously close all open files and database requests at the end of each run of the function. I also tried to use different flush methods, sleep(), and what’s not. But the fact remains the same - the server monitors the execution as if it is a normal browser request and times it out after a few runs.

    Is there a way to imitate a server-side command line call from within MODx? And also, is there some scheduling capabilities (not the existing event-driven plugin methods) to MODx that I am not aware of?

    Many thanks.
      Cheers,
      Shlomo Tommer
      • 10449
      • 956 Posts
      imho, a script that runs for 400 seconds belongs in a cron job.

      Try to set special headers in your script:

      ini_set('max_execution_time', 6000); // seconds
      ini_set('ignore_user_abort', 1);


      What do you mean with "one million documents"? Are they actual modx documents? Do you generate the sitemap via Ditto, or your own php script?

      re: inherent scheduling capabilities inside modx 0.9.6
      No, I don’t think so.
        • 27072
        • 76 Posts
        Many thanks, dear ganeshXL, for your support.

        I used Ditto at first and dropped it - for this purpose - for one reason or the other, which i can no longer remember.

        For the ~800,000 pages on the site, I employ 10 MODx documents. Rendering is totally database driven.

        Do I need to re-initialize ini_set and ini_set at the end of the MODx job?

        Thanks so much.
          Cheers,
          Shlomo Tommer
          • 10449
          • 956 Posts
          Do I need to re-initialize ini_set and ini_set at the end of the MODx job?

          No, ini_set inside a php script is only valid for that particular script.
          -> http://ch.php.net/ini_set
          The configuration option will keep this new value during the script’s execution, and will be restored at the script’s ending.