| Create_db | Import_db | Export_db | Reindex_db | Pack_db |
| Add_Task | Edit_Task | Delete_Task | Undelete_Task | Docs |
What Does Once_A_Day do?
Why only once a day?
How does it work?
How do I use it on my site?
This software provides the tools required to automatically run any existing Miva script, or function within any existing Miva script, once each day. Think of it as a limited CRON subsitute for people without CRON.
It has two primary limitations. First, you shouldn't give it tasks that take more than about 30 seconds to process and second, it only processes each task one time per day.
When a host doesn't provide CRON, the two reasons usually given are "it would be abused by newbies running lots of tasks real close together thereby degrading server response" and "CRON is too difficult to support". Although I'm also concerned about server hogs (NIMBY :), I feel the ability to automate a task is too important of a tool to lose because some newbies may abuse it.
I've addressed the hosting concerns by designing this software to only run each task once per day and to run all tasks as close to midnight server time as possible. Since this is open source software, any reasonably competent Miva programmer can figure out how to change the timer but I think anyone at that skill level will also have the knowledge and desire to use this software reponsibly.
And since this is not software supplied by the host, they don't have to support it. Hopefully I've done a good enough job that you won't even need to contact me :).
CRON runs in the background so your visitors don't know its running. Unfortunately Miva can not run in the background so additional Miva processing shows up as an increased delay in the page being served to the visitor.
This software works by attaching a task onto one of your visitor's requests for a page. The visitor will only be used once, to process one task, then their IP address is granted an one hour exemption (by which time they'll probably be long gone and someone else will be using that IP address). Another visitor will be chosen if another task needs to be processed. To your visitor it will seem like one of the pages from your site took longer to load than the others but since it only happened once they'll probably chalk it up to a temporary internet glitch.
Using this method requires you to practise restraint. If the tasks you run take too long to process then your visitor may think something is wrong and reload the page or, in the worst case, the combined time to process the task and serve the page will take longer than your global timeout and your visitor will get an error message.
Another implicatation of using this method is that the more visitors to your site the faster your daily tasks will be completed. For example if you only have ten visitors per day to your site and the first visitor accesses your site at 10 AM then the first task won't be completed until 10 AM and you can only process a maximum of ten tasks per day (one per visitor).
<MvDO FILE = "/path/to/once_a_day.mv"
NAME = ""
VALUE = "{Run_Tasks()}">
<MvDO FILE = "/path/to/once_a_day.mv"
NAME = "g.MyVarName"
VALUE = "{Run_Tasks()}">
The simplest way to use this software is to add the first chunk of code to each of the Miva scripts on your site and design all of your tasks to complete all of the processing required for that task. But sometimes that uses too much time and you must split your tasks into subtasks. The second chunk of code may be useful if you need to split up your tasks.
You can also use server side includes to run Once_A_Day by writing a "stand-alone" script (named "includes.mv" for example) that only contains the first chunk of code above, then adding this line in your ".shtml" documents:
<!--#include virtual="/cgi-bin/miva?path/to/includes.mv" -->
Note: Your SSI server requirements may differ. Contact your tech support if that code doesn't work on your server.
You can place the code any place in your script that you want. For example if it is at the very top of your script then it will run every time that script is accessed... but if the script displays multiple pages then adding the code to the very top will waste processing time because Once_A_Day will have to check the IP address each time the visitor goes to the next page. In that situation its more efficient to place the chunk of code in a area of your script that is only processed once for each visitor (ie: the introduction page for the script).
A Once_A_Day task can be any script or function stored in a script. The miva code for the task is not stored in the task database... only the path/filename of the task is stored in the database.
Write the Miva code for your task and upload it to your server. For security, you can write your tasks as functions in a library then put a MvEXIT as the first line in the library. That will ensure your tasks can only be run by Once_A_Day or another script on your server.
After uploading your task, whether stand-alone or function library, use the "Add_Task" option on your online version of this file to add the new task's info to the database.
And thats it! Your first visitor after midnight server time to access one of the Miva scripts that you added the code to will be used to process the first of your daily tasks, the second visitor will be used for the second task, and so on.
Brian R. Bullock
brian@wwwebweaver.com
http://wwwebweaver.com/func_junc/
Released to the public domain June 24, 2001
Need a free Miva editor? Check out:
| |||||
| | |||||