My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Links

Example task: you have a live queue of emails(for example in DB) that must be sent as soon as possible.

  1. You need to have some PHP-script that will check if there are any emails in queue, and if yes so send them.
  2. This PHP-script must be runned all time, and check queue every second.
  3. Only one instance of this PHP-script can be runned, to be sure that one email was not sent twice.
  4. PHP-script can be interrupted in any moment by some error, so in this case it must be restarted as soon as possible.
  5. PHP-script can have a bug on some iteration, mean: it will be lunched but not sending emails, so in this case it must be restarted as soon as possible.
  6. PHP-script should be restarted every 5-10 hours to prevent memory leaks and do it in safe way (when all current tasks are complete).
  7. Ability to stop script in any moment.

What you do:

  1. Use ScriptAlone in way like in this PHP-script.
  2. Configure CRON that will run this PHP-script every 5 minutes.

What you have:

  1. Script will be runned all time, and checked emails every second.
  2. There will be only one instance of runned script.
  3. Script will be restarted if there will be any errors or iteration time limit expire.
  4. Script will be restarted in safe way every 5 hours.
  5. You can any time check if script is runned by checking existing file with $stateFilepath path (./examples.php.works)
  6. You can any time stop runned script by creating file with path $stateFilepath.'.stop' (./examples.php.works.stop).
  7. All script restarts takes maximum 5 minutes (because of CRON try to run next script instance every 5 minute).

Recommended

Powered by Google Project Hosting