ControlScripts: add support for infinite time in (t1, t2) periods when scheduling...
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tue, 3 Aug 2010 17:23:00 +0000 (20:23 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tue, 3 Aug 2010 17:23:00 +0000 (20:23 +0300)
ControlScripts/schedule_client.sh

index 795e40e..ebb232b 100755 (executable)
@@ -65,6 +65,17 @@ resume_client()
        kill -CONT ${client_pid}
 }
 
+# test whether time in period (t1, t2) is infinte ("-" sign)
+# if that is the case, sleep indefinitely, waiting for shut down
+test_infinte()
+{
+       time="$1"
+
+       if test "$time" = "-"; then
+               sleep 1000d
+       fi
+}
+
 parse_periods
 
 DEBUG echo "start_time is ${start_time}"
@@ -79,6 +90,8 @@ DEBUG echo "background_pid is ${background_pid}"
 old_time=${start_time}
 
 for ((i = 0; i < ${#suspend_resume[@]}; i += 2)); do
+       test_infinite ${suspend_resume[$i]}
+
        to_sleep=$((${suspend_resume[$i]} - ${old_time}))
        sleep ${to_sleep}
        client_pid=$(pgrep -P ${background_pid})
@@ -86,12 +99,16 @@ for ((i = 0; i < ${#suspend_resume[@]}; i += 2)); do
        suspend_client ${client_pid}
        old_time=${suspend_resume[$i]}
 
+       test_infinite ${suspend_resume[$(($i+1))]}
+
        to_sleep=$((${suspend_resume[$(($i+1))]} - ${old_time}))
        sleep ${to_sleep}
        resume_client ${client_pid}
        old_time=${suspend_resume[$(($i+1))]}
 done
 
+test_infinite ${stop_time}
+
 to_sleep=$((${stop_time} - ${old_time}))
 sleep ${to_sleep}
 stop_client ${client_type}