Background Task Launching
Dvelum 0.9.3
Background tasks are launched with console command:
cd /path/to/project/ && php ./console.php /[controller]/[action]/[time_limit]/[thread] (/path/to/project/ - one level up www directory).
[controller] - controller code as defined in Frontend management module. In fact, this is the ‘console’ controller [Frontend_Console_Controller] which is included in the installation package. It should be used only in console mode. User authorization parameters are defined in configuration file.
[action] - action name, e. g. ‘dosmth’ for public function dosmthAction.
[time_limit] - execution time limit. Most of Frontend_Console_Controller actions block concurrent execution with the help of file locks.
[thread] - thread number, for launching the same process in several threads.
File www/system/config/cronjob.php contains the list of background tasks and their settings. cron_config section describes default settings and locking parameters.
For most tasks the ‘adapter’ parameter may be supplied in config. It is the actual performer of the task.
If process should run under specific user account, user id may be specified.
There are 2 basic realizations for different types of tasks. A cronjob adapter may extend Cronjob_Abstract or Task_Cronjob_Abstract classes. Both adapter types use file locks to prevent concurrent execution.
Task_Cronjob_Abstract task execution process can be monitored in background task management interface. They can receive signals or control commands. In other words, they run in Bgtask mode. Sometimes this functionality is superfluous. Then Cronjob_Abstract based adapter should be used. Note that Task_Cronjob_Abstract uses memory tables (this type of tables should be allowed in Mysql settings). Also we advise to create memory clearing process if there are any active background tasks. (clearmemory)