From: Razvan Deaconescu Date: Tue, 3 Aug 2010 15:50:38 +0000 (+0300) Subject: update schedule_client.sh and client_script_mappings; working version - tested on... X-Git-Tag: classic-scenario-config~1 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=1a512bad42ab2434a88f502379c082b659e481eb;p=p2p-testing-infrastructure.git update schedule_client.sh and client_script_mappings; working version - tested on p2p@p2p-next-01.grid.pub.ro:10122 --- diff --git a/ConfigFiles/client_script_mappings b/ConfigFiles/client_script_mappings index e86992a..337fed4 100644 --- a/ConfigFiles/client_script_mappings +++ b/ConfigFiles/client_script_mappings @@ -8,17 +8,17 @@ start_client() { local client_type=$1 - local client_pid=$1 + local torrent_file=$2 DEBUG echo "starting client ..." case "${client_type}" in "hrktorrent_seeder") ./start_hrk_seeder.sh ${torrent_file} & - return $(pgrep -P $!) + return $! ;; "hrktorrent_leecher") ./start_hrk_leecher.sh ${torrent_file} & - return $(pgrep -P $!) + return $! ;; esac } diff --git a/ControlScripts/schedule_client.sh b/ControlScripts/schedule_client.sh index fc40be0..3bf5e5c 100755 --- a/ControlScripts/schedule_client.sh +++ b/ControlScripts/schedule_client.sh @@ -53,12 +53,14 @@ parse_periods() suspend_client() { + local client_pid=$1 DEBUG echo "suspending client ..." kill -STOP ${client_pid} } resume_client() { + local client_pid=$1 DEBUG echo "resuming client ..." kill -CONT ${client_pid} } @@ -71,21 +73,25 @@ DEBUG echo "stop_time is ${stop_time}" to_sleep=${start_time} sleep ${to_sleep} -start_client +start_client ${client_type} ${torrent_file} +background_pid=$! +DEBUG echo "background_pid is ${background_pid}" old_time=${start_time} for ((i = 0; i < ${#suspend_resume[@]}; i += 2)); do to_sleep=$((${suspend_resume[$i]} - ${old_time})) sleep ${to_sleep} - suspend_client + client_pid=$(pgrep -P ${background_pid}) + DEBUG echo "client_pid is ${client_pid}" + suspend_client ${client_pid} old_time=${suspend_resume[$i]} to_sleep=$((${suspend_resume[$(($i+1))]} - ${old_time})) sleep ${to_sleep} - resume_client + resume_client ${client_pid} old_time=${suspend_resume[$(($i+1))]} done to_sleep=$((${stop_time} - ${old_time})) sleep ${to_sleep} -stop_client +stop_client ${client_type}