| 94 | #サーバビジーで即死してないか検出 |
---|
| 95 | $now = time(); |
---|
| 96 | if ($now < $endepochtime){ #終了予定より前に録音プロセスが戻ってきたなら |
---|
| 97 | &writelog("recwrap radiko rec failed,will be retry. NOW:$now PlanedEnd:$endepochtime"); |
---|
| 98 | |
---|
| 99 | my $retrycounter = 0; |
---|
| 100 | my $waitsecsbase = 10; |
---|
| 101 | my $waitsec ; |
---|
| 102 | my $waitsecsrand ; |
---|
| 103 | my $recfilepath; |
---|
| 104 | while($now < $endepochtime){ |
---|
| 105 | if($retrycounter >= 15){ |
---|
| 106 | &writelog("recwrap radiko rec failed,Giving up.Max retry counter over."); |
---|
| 107 | last; |
---|
| 108 | } |
---|
| 109 | $waitsecsrand = int(rand($waitsecsbase/2)); |
---|
| 110 | $waitsec = $waitsecsbase + $waitsecsrand ; |
---|
| 111 | &writelog("recwrap DEBUG radiko rec retry waiting. $waitsec ($waitsecsbase + $waitsecsrand)"); |
---|
| 112 | sleep($waitsec); |
---|
| 113 | &writelog("recwrap DEBUG retry start."); |
---|
| 114 | $recfilepath = "$recfolderpath"."/"."$outputfilename"; |
---|
| 115 | if (-e $recfilepath ){ |
---|
| 116 | unlink("$recfilepath"); |
---|
| 117 | &writelog("recwrap DEBUG delete $recfilepath"); |
---|
| 118 | } |
---|
| 119 | #録音 |
---|
| 120 | $oserr = system("$toolpath/perl/digitalradiorecording.pl $radikostationname $reclength $outputfilename N");#起動waitなしで |
---|
| 121 | $oserr = $oserr / 256; |
---|
| 122 | &writelog("recwrap DEBUG radiko rec retry finished. $oserr"); |
---|
| 123 | |
---|
| 124 | $retrycounter++; |
---|
| 125 | if ($waitsecsbase < 600 ){ |
---|
| 126 | $waitsecsbase = $waitsecsbase * 2; |
---|
| 127 | } |
---|
| 128 | $now = time(); |
---|
| 129 | }# while |
---|
| 130 | } # if |
---|
| 131 | |
---|