LongTask
From ISPWiki
BILLmanager 4.0.49 contains updated LongTask. The old version can be found here.
Main changes:
- Parameters are now passed through the command line. They can be passed through the third file descriptor as well for backward compatibility;
- The program is no longer restarted once failed;
- The Background tasks module is now available in the control panel's menu.
- The queue mechanism is now available.
LongTask provides utility features for long task execution. BILLmanager performs the following actions when initializing a new task:
- A PID-file is created. The file can be located in one of the following places: a task to be added to queue - /usr/local/ispmgr/var/run/billmgr/queue_name; a common task - /usr/local/ispmgr/var/run/billmgr. The first line of the PID-file shows current task status, the others contain start parameters.
The following statuses can be shown:
- RUN - a task has started;
- QUE - a task is standing in a queue;
- OK - a task has been successfully completed;
- ERR - an error occurred while processing a task.
- A background task runs and receives startup options as the command line options. Required environment variables are specified, and the PID-file is locked.
- The system is awaiting a response from the background task and monitor its status. If a background task crashes, the content of the PID-file will be changed into "ERR crashed".
Upon completion each LongTask informs BILLmanager about its status by calling either of the BILLmanager functions:
- If the task completed successfully:
/usr/local/ispmgr/sbin/mgrctl -m corresponding_software_name longtask.finish elid=path_to_pid-file status=ok
- In case of error:
/usr/local/ispmgr/sbin/mgrctl -m corresponding_software_name longtask.finish&elid=path_to_pid-file status=err&errmsg=error_description
where:
- corresponding_software_name - billmgr, if BILLmanager is used
- path_to_pid-file- path to the LongTask pid-file - you can get this parameter from the MGR_LT_PID environment variable.
