# HG changeset patch # User Christophe Lincoln # Date 1304811602 -7200 # Node ID 5d21241ca8114328988c05921d8158adc8711960 # Parent 1b9322fabdf3e89160bf5e19be7d4709f17bf76e Add PID support so when running with cron we dont mess up commits diff -r 1b9322fabdf3 -r 5d21241ca811 cooker --- a/cooker Sun May 08 00:24:38 2011 +0200 +++ b/cooker Sun May 08 01:40:02 2011 +0200 @@ -25,6 +25,9 @@ broken="$CACHE/broken" cooknotes="$CACHE/cooknotes" +# PID file. +pidfile='/var/run/cooker.pid' + # # Functions # @@ -79,9 +82,10 @@ fi } -# Clean up after cook success. -empty_command() { +# Clean up before exit when check and cook commits finish. +clean_exit() { rm -f $command && touch $command + rm -f $pidfile } # Summary for commits. @@ -288,7 +292,7 @@ pkg|-p) # Same as 'cook pkg' but with log for web interface. cook $pkg || broken - empty_command ;; + clean_exit ;; cat|-c) # Cook all packages of a category. cat="$2" @@ -355,13 +359,22 @@ cook_order | tee $LOGS/cookorder.log cook_list ;; *) - # Default is to cook all commits. + # Default is to cook all commits if not yet running. [ "$1" ] && usage cooklist=$CACHE/commits + if [ -f "$pidfile" ]; then + pid=$(cat /var/run/cooker.pid) + gettext -e "\nStill cooking latest commits with pid:" + echo -e " $pid\n" && exit 0 + fi + + # Start and get a PID file. rm -f $LOGS/commits.log echo "" echo "Checking for commits" | log_commits separator | tee -a $LOGS/commits.log + gettext "Starting with PID: " + echo $$ | tee $pidfile # Get revisions. cd $wok || exit 1 @@ -381,7 +394,7 @@ else echo "No revision changes: $cur vs $new" | log separator | log_commits - empty_command && echo "" && exit 0 + clean_exit && echo "" && exit 0 fi # Get and display modifications. @@ -408,7 +421,8 @@ echo "" strip_blocked cook_order | tee $LOGS/cookorder.log - cook_commits && empty_command ;; + cook_commits + clean_exit ;; esac exit 0