changeset 27:f93693980ead

myrss: limit number of forked processes; tweak indexing; print both stdout and stderr from shell script to php page
author paulo@thepaulopc
date Sat, 04 Jun 2011 22:20:26 -0700
parents 56bb0cbf5385
children 28221b9bb370
files myrss/index.php myrss/myrss_update.sh
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/myrss/index.php	Sat Jun 04 22:17:24 2011 -0700
     1.2 +++ b/myrss/index.php	Sat Jun 04 22:20:26 2011 -0700
     1.3 @@ -11,7 +11,7 @@
     1.4  $newbody = '';
     1.5  
     1.6  if ((time() - $cache_mtime >= $cache_life)) {
     1.7 -	$newbody = shell_exec('./myrss_update.sh');
     1.8 +	$newbody = shell_exec('./myrss_update.sh 2>&1');
     1.9  	file_put_contents($cache_fn, $newbody);
    1.10  } else {
    1.11  	$newbody = file_get_contents($cache_fn);
     2.1 --- a/myrss/myrss_update.sh	Sat Jun 04 22:17:24 2011 -0700
     2.2 +++ b/myrss/myrss_update.sh	Sat Jun 04 22:20:26 2011 -0700
     2.3 @@ -2,12 +2,19 @@
     2.4  
     2.5  TIMESTAMP=$(date '+%FT%T%:z')
     2.6  TIMEOUT=60
     2.7 +MAXPROCS=20
     2.8  
     2.9  i=0
    2.10 +n=0
    2.11  for URL in $(grep -v '^#' FEEDS)
    2.12  do
    2.13 -	FN=$((i++)).feedtmp
    2.14 -	wget -q -T ${TIMEOUT} -U '' -O - ${URL} | xsltproc step1.xsl - | xsltproc step2.xsl - > ${FN} &
    2.15 +	FN=$((++i)).feedtmp
    2.16 +	wget -q -T ${TIMEOUT} -U '' -O - ${URL} | xsltproc step1.xsl - | xsltproc step2.xsl - > ${FN} & 
    2.17 +	if (( $((++n)) > ${MAXPROCS} ))
    2.18 +	then
    2.19 +		wait
    2.20 +		n=0
    2.21 +	fi
    2.22  done 
    2.23  
    2.24  wait
    2.25 @@ -21,7 +28,7 @@
    2.26  echo '<BODY>'
    2.27  echo "<H1>${TIMESTAMP}</H1>"
    2.28  
    2.29 -for j in $(seq 0 ${i})
    2.30 +for j in $(seq 1 ${i})
    2.31  do
    2.32  	cat ${j}.feedtmp
    2.33  done