LongTask. Old version

From ISPWiki

Jump to: navigation, search

Please note! BILLmanager 4.0.49 contains updated LongTask. More information can be found here.

LongTask allows to use utility features for long task execution. The main task starts a slave one and leaves the third file descriptor that is used to pass parameters open allowing the master process to get a result. The files in the /usr/local/ispmgr/var/run directory are checked every several minutes. If an unblocked RUN file is found in the first line, LongTask restarts. Parameters are passed to the file as follows:


If a task has been successfully completed, you need to delete the file's content and specify:


If an error occurred, you need to delete the file's content and specify:

 ERR error_notification\n

Then call:

 /usr/local/ispmgr/sbin/mgrctl -m  longtask corresponding_software_name

Use billmgr for BILLmanager.

Example on Perl

 open(DEBUG, ">>/tmp/debug.log");
 open (FD3, '<&3');	
 my @ltparams;
 my $count = 0;
 while (<FD3>) {		
   $ltparams[$count] = $_;
   $count = $count + 1;
 if ($count){
   print DEBUG "longtask";
   my $res = longtask();
   open (FD3, '>&3');
   seek(FD3, 0, 0);
   truncate(FD3, 0);
     print FD3 "ERR $res\n";
   } else {
     print FD3 "OK!\n";
   system "/usr/local/ispmgr/sbin/mgrctl -m billmgr longtask";
 } else {
   #it is not LongTask, so you may work in a ordinary course.
 sub longtask(){
   #Here you may read parameters from the @ltparams array
   #In case of error, you need to return a non-blank line. 
Was this helpful? Yes | No
Personal tools