Changeset 25 for trunk/cleanup.php
- Timestamp:
- Jan 13, 2017, 1:30:29 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cleanup.php
r24 r25 17 17 function aira_cleanup( $us3_db, $reqID, $gfac_link ) 18 18 { 19 global $org_domain; 19 20 global $dbhost; 20 21 global $user; … … 141 142 list( $status, $cluster, $id ) = mysql_fetch_array( $result ); 142 143 143 if ( $cluster == 'bcf-local' || $cluster == 'alamo-local' ) 144 $is_us3iab = preg_match( "/us3iab/", $cluster ); 145 $is_local = preg_match( "/-local/", $cluster ); 146 147 if ( $is_us3iab || $is_local ) 144 148 { 145 149 $clushost = $cluster; … … 191 195 $fn_tarfile = "analysis-results.tar"; 192 196 $num_try = 0; 197 $len1 = strlen( $fn_tarfile ); 198 write_log( "$me: fn_tarfile=$fn_tarfile len(tar)=$len1" ); 193 199 while ( ! file_exists( $fn_tarfile ) && $num_try < 3 ) 194 200 { 195 201 sleep( 10 ); 196 202 $num_try++; 203 write_log( "$me: tar-exists: num_try=$num_try" ); 197 204 } 198 205 … … 200 207 foreach ( $ofiles as $ofile ) 201 208 { 202 if ( preg_match( "/ .*stderr$/", $ofile ) )209 if ( preg_match( "/^" . $gfacID . ".*stderr$/", $ofile ) ) 203 210 $fn_stderr = $ofile; 204 if ( preg_match( "/ .*stdout$/", $ofile ) )211 if ( preg_match( "/^" . $gfacID . ".*stdout$/", $ofile ) ) 205 212 $fn_stdout = $ofile; 206 213 //write_log( "$me: ofile=$ofile" ); … … 654 661 global $editXMLFilename; 655 662 global $stdout; 663 global $org_domain; 656 664 657 665 global $me; … … 697 705 $limshost = $dbhost; 698 706 if ( $limshost == 'localhost' ) 707 { 699 708 $limshost = gethostname(); 709 if ( ! preg_match( "/\./", $limshost ) ) 710 $limshost = $limshost . $org_domain; 711 } 700 712 701 713 // Parse the editXMLFilename … … 841 853 global $db; 842 854 global $status; 843 844 // Figure out local working directory 845 if ( ! is_dir( "$work/$gfacID" ) ) mkdir( "$work/$gfacID", 0770 ); 846 $pwd = chdir( "$work/$gfacID" ); 855 $is_us3iab = preg_match( "/us3iab/", $cluster ); 847 856 848 857 // Figure out remote directory 849 858 $remoteDir = sprintf( "$work_remote/$db-%06d", $requestID ); 859 write_log( "$me: is_us3iab=$is_us3iab remoteDir=$remoteDir" ); 850 860 851 861 // Get stdout, stderr, output/analysis-results.tar 852 862 $output = array(); 853 // $cmd = "scp us3@$cluster.uthscsa.edu:$remoteDir/stdout . 2>&1"; 854 // 855 // exec( $cmd, $output, $stat ); 856 // if ( $stat != 0 ) 857 // write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 858 // 859 // $cmd = "scp us3@$cluster.uthscsa.edu:$remoteDir/stderr . 2>&1"; 860 // exec( $cmd, $output, $stat ); 861 // if ( $stat != 0 ) 862 // write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 863 864 $cmd = "scp us3@$cluster.uthscsa.edu:$remoteDir/output/analysis-results.tar . 2>&1"; 865 exec( $cmd, $output, $stat ); 866 if ( $stat != 0 ) 867 write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 868 869 $cmd = "scp us3@$cluster.uthscsa.edu:$remoteDir/stdout . 2>&1"; 870 exec( $cmd, $output, $stat ); 871 if ( $stat != 0 ) 872 { 873 write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 874 sleep( 10 ); 875 write_log( "$me: RETRY" ); 863 864 if ( $is_us3iab == 0 ) 865 { 866 // Figure out local working directory 867 if ( ! is_dir( "$work/$gfacID" ) ) mkdir( "$work/$gfacID", 0770 ); 868 $pwd = chdir( "$work/$gfacID" ); 869 870 $cmd = "scp us3@$cluster.uthscsa.edu:$remoteDir/output/analysis-results.tar . 2>&1"; 871 876 872 exec( $cmd, $output, $stat ); 877 if ( $stat != 0 ) 873 if ( $stat != 0 ) 878 874 write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 879 } 880 881 $cmd = "scp us3@$cluster.uthscsa.edu:$remoteDir/stderr . 2>&1"; 882 exec( $cmd, $output, $stat ); 883 if ( $stat != 0 ) 884 { 885 write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 886 sleep( 10 ); 887 write_log( "$me: RETRY" ); 875 876 $cmd = "scp us3@$cluster.uthscsa.edu:$remoteDir/stdout . 2>&1"; 877 888 878 exec( $cmd, $output, $stat ); 889 if ( $stat != 0 ) 879 if ( $stat != 0 ) 880 { 890 881 write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 891 } 882 sleep( 10 ); 883 write_log( "$me: RETRY" ); 884 exec( $cmd, $output, $stat ); 885 if ( $stat != 0 ) 886 write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 887 } 888 889 $cmd = "scp us3@$cluster.uthscsa.edu:$remoteDir/stderr . 2>&1"; 890 891 exec( $cmd, $output, $stat ); 892 if ( $stat != 0 ) 893 { 894 write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 895 sleep( 10 ); 896 write_log( "$me: RETRY" ); 897 exec( $cmd, $output, $stat ); 898 if ( $stat != 0 ) 899 write_log( "$me: Bad exec:\n$cmd\n" . implode( "\n", $output ) ); 900 } 901 } 902 else 903 { 904 $pwd = chdir( "$remoteDir" ); 905 write_log( "$me: IS US3IAB: pwd=$pwd $remoteDir"); 906 } 907 892 908 893 909 // Write the files to gfacDB 894 910 895 if ( file_exists( "stderr" ) ) $stderr = file_get_contents( "stderr" ); 911 if ( file_exists( "stderr" ) ) 912 { // Filter stderr to not have libnnls debug lines 913 exec( "mv stderr stderr+nnls", $output, $stat ); 914 exec( "grep -vi nnls stderr+nnls >stderr", $output, $stat ); 915 $stderr = file_get_contents( "stderr" ); 916 } 917 else 918 $stderr = ""; 896 919 if ( file_exists( "stdout" ) ) $stdout = file_get_contents( "stdout" ); 897 if ( file_exists( "analysis-results.tar" ) ) 898 $tarfile = file_get_contents( "analysis-results.tar" ); 899 920 $fn1_tarfile = "analysis-results.tar"; 921 $fn2_tarfile = "output/" . $fn1_tarfile; 922 if ( file_exists( $fn1_tarfile ) ) 923 $tarfile = file_get_contents( $fn1_tarfile ); 924 else if ( file_exists( $fn2_tarfile ) ) 925 $tarfile = file_get_contents( $fn2_tarfile ); 926 927 $lense = strlen( $stderr ); 928 if ( $lense > 1000000 ) 929 { // Replace exceptionally large stderr with smaller version 930 exec( "mv stderr stderr-orig", $output, $stat ); 931 exec( "head -n 5000 stderr-orig >stderr-h", $output, $stat ); 932 exec( "tail -n 5000 stderr-orig >stderr-t", $output, $stat ); 933 exec( "cat stderr-h stderr-t >stderr", $output, $stat ); 934 $stderr = file_get_contents( "stderr" ); 935 } 936 $lent = strlen( $tarfile ); 937 write_log( "$me: tarfile size: $lent"); 938 $lene = strlen( $stderr ); 939 write_log( "$me: stderr size: $lene (was $lense)"); 940 $leno = strlen( $stdout ); 941 write_log( "$me: stdout size: $leno"); 942 $estarf=mysql_real_escape_string($tarfile,$gfac_link); 943 $lenf = strlen($estarf); 944 write_log( "$me: es-tarfile size: $lenf"); 945 $esstdo=mysql_real_escape_string($stdout,$gfac_link); 946 $leno = strlen($esstdo); 947 write_log( "$me: es-stdout size: $leno"); 948 $esstde=mysql_real_escape_string($stderr,$gfac_link); 949 $lene = strlen($esstde); 950 write_log( "$me: es-stderr size: $lene"); 900 951 $query = "UPDATE analysis SET " . 901 952 "stderr='" . mysql_real_escape_string( $stderr, $gfac_link ) . "'," .
Note:
See TracChangeset
for help on using the changeset viewer.