diff --git a/PseudoChannel.py b/PseudoChannel.py index e3e1ef4..6c3e9ce 100644 --- a/PseudoChannel.py +++ b/PseudoChannel.py @@ -596,6 +596,10 @@ class PseudoChannel(): logging.info("##### Dropping previous daily_schedule database") + self.db.remove_all_daily_scheduled_items() + + sleep(1) + if self.USING_COMMERCIAL_INJECTION: self.commercials = PseudoChannelCommercial( self.db.get_commercials(), @@ -764,8 +768,6 @@ class PseudoChannel(): previous_episode = None - self.db.remove_all_daily_scheduled_items() - for entry in self.MEDIA: #print entry.natural_end_time diff --git a/startstop.sh b/startstop.sh index f125621..1b89f6b 100755 --- a/startstop.sh +++ b/startstop.sh @@ -3,7 +3,7 @@ # file: startstop.sh #---- -# Simple script to start / stop PseudoChannel.py +# Simple script to start / stop a python script in the background. #---- #---- @@ -26,12 +26,14 @@ VIRTUAL_ENV_DIR="env" #----END EDITABLE VARS------- +# If virtualenv specified & exists, using that version of python instead. if [ -d "$VIRTUAL_ENV_DIR" ]; then PYTHON_TO_USE="$VIRTUAL_ENV_DIR/bin/python" fi +# If the .pid file doesn't exist (let's assume no processes are running)... if [ ! -e "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" ]; then # If the running.pid file doesn't exists, create it, start PseudoChannel.py and add the PID to it. @@ -54,6 +56,8 @@ else kill "$the_pid" + COUNTER=1 + while [ -e /proc/$the_pid ] do @@ -62,8 +66,24 @@ else sleep .7 + COUNTER=$[$COUNTER +1] + + if [ $COUNTER -eq 20 ]; then + + kill -9 "$the_pid" + + fi + + if [ $COUNTER -eq 40 ]; then + + exit 1 + + fi + done echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid has finished" -fi \ No newline at end of file +fi + +exit 0 \ No newline at end of file