You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

run.sh 2.9 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/local
  2. python_dir=/usr/local/PlayerCode/CAPI/python/PyAPI
  3. python_main_dir=/usr/local/PlayerCode/CAPI/python
  4. playback_dir=/usr/local/playback
  5. if [ $EXPOSED -eq 1 ]; then
  6. nice -10 ./Server --port 8888 --studentCount 4 --trickerCount 1 --resultFileName $playback_dir/result --gameTimeInSecond $TIME --mode $MODE --mapResource $MAP --url $URL --token $TOKEN --fileName $playback_dir/video --startLockFile $playback_dir/start.lock > $playback_dir/server.log 2>&1 &
  7. server_pid=$!
  8. else
  9. nice -10 ./Server --port 8888 --studentCount 4 --trickerCount 1 --resultFileName $playback_dir/result --gameTimeInSecond $TIME --mode $MODE --mapResource $MAP --notAllowSpectator --url $URL --token $TOKEN --fileName $playback_dir/video --startLockFile $playback_dir/start.lock > $playback_dir/server.log 2>&1 &
  10. server_pid=$!
  11. fi
  12. sleep 5
  13. for k in {1..2}
  14. do
  15. pushd /usr/local/team$k
  16. if [ $k -eq 1 ]; then
  17. for i in {1..4}
  18. do
  19. j=$((i - 1))
  20. if [ -f "./player$i.py" ]; then
  21. cp -r $python_main_dir $python_main_dir$i
  22. cp -f ./player$i.py $python_main_dir$i/PyAPI/AI.py
  23. nice -0 python3 $python_main_dir$i/PyAPI/main.py -I 127.0.0.1 -P 8888 -p $j > $playback_dir/team$k-player$j.log 2>&1 &
  24. elif [ -f "./capi$i" ]; then
  25. nice -0 ./capi$i -I 127.0.0.1 -P 8888 -p $j > $playback_dir/team$k-player$j.log 2>&1 &
  26. else
  27. echo "ERROR. $i is not found."
  28. fi
  29. done
  30. else
  31. for i in {5..5}
  32. do
  33. j=$((i - 1))
  34. if [ -f "./player$i.py" ]; then
  35. cp -r $python_main_dir $python_main_dir$i
  36. cp -f ./player$i.py $python_main_dir$i/PyAPI/AI.py
  37. nice -0 python3 $python_main_dir$i/PyAPI/main.py -I 127.0.0.1 -P 8888 -p $j > $playback_dir/team$k-player$j.log 2>&1 &
  38. elif [ -f "./capi$i" ]; then
  39. nice -0 ./capi$i -I 127.0.0.1 -P 8888 -p $j > $playback_dir/team$k-player$j.log 2>&1 &
  40. else
  41. echo "ERROR. $i is not found."
  42. fi
  43. done
  44. fi
  45. popd
  46. done
  47. sleep 10
  48. if [ -f $playback_dir/start.lock ]; then
  49. ps -p $server_pid
  50. while [ $? -eq 0 ]
  51. do
  52. sleep 1
  53. ps -p $server_pid > /dev/null 2>&1
  54. done
  55. # result=$(cat /usr/local/playback/result.json)
  56. # score0=$(echo "$result" | grep -oP '(?<="Student":)\d+')
  57. # score1=$(echo "$result" | grep -oP '(?<="Tricker":)\d+')
  58. # curl $URL -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"result":[{"team_id":0, "score":'${score0}'}, {"team_id":1, "score":'${score1}'}], "mode":'${MODE}'}'> $playback_dir/send.log 2>&1
  59. touch $playback_dir/finish.lock
  60. echo "Finish"
  61. else
  62. echo "Failed to start game."
  63. touch $playback_dir/finish.lock
  64. touch temp.lock
  65. mv -f temp.lock $playback_dir/video.thuaipb
  66. kill -9 $server_pid
  67. fi