Changeset 3175


Ignore:
Timestamp:
03/03/10 16:45:00 (15 years ago)
Author:
Eric.Larour
Message:

Added tunnel capability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/public/waitonlock.m

    r2656 r3175  
    1 function flag=waitonlock(md,executionpath)
     1function flag=waitonlock(md,executionpath,login,port)
    22%WAITONLOCK - wait for a file
    33%
     
    1515%waitonlock will work if the lock is on the same machine only:
    1616if ~strcmpi(oshostname(),cluster),
    17         disp('solution launched on remote cluster. log in to detect job completion.');
    18         choice=input('Is the job successfully completed? (y/n)','s');
    19         if ~strcmp(choice,'y'),
    20                 disp('Results not loaded... exiting');
    21                 flag=0;
     17
     18        if port,
     19                %there is a tunnel, so we have a short at looking for the lock file.
     20
     21                disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)'])
     22                time=0; ispresent=0;
     23                while (ispresent==0 & time<timelimit)
     24                        [status, result]=system(['ssh -q -p ' num2str(port) ' ' login '@localhost "if ( -e ' executionpath '/' md.name '.lock ) echo 1"']);
     25                        ispresent=~isempty(result);
     26                        pause(10); %tunnel can be unstable, let's not use it too much
     27                        time=time+1/60;
     28                end
     29               
     30                %build output
     31                if (time>timelimit),
     32                        disp('Time limit exceeded. Increase md.waitonlock');
     33                        disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
     34                        error(['waitonlock error message: time limit exceeded']);
     35                        flag=0;
     36                else
     37                        flag=1;
     38                end
    2239        else
    23                 flag=1;
     40                disp('solution launched on remote cluster. log in to detect job completion.');
     41                choice=input('Is the job successfully completed? (y/n)','s');
     42                if ~strcmp(choice,'y'),
     43                        disp('Results not loaded... exiting');
     44                        flag=0;
     45                else
     46                        flag=1;
     47                end
    2448        end
    2549
Note: See TracChangeset for help on using the changeset viewer.