Created
September 28, 2021 23:07
-
-
Save csullivan/2ceb047e26bbb2bb39fbedd91fb91150 to your computer and use it in GitHub Desktop.
Expect script to restart TVM RPC server on Android after crash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function run() { | |
device_id=$1 | |
echo "Starting rpc server on adb device: $device_id" | |
preamble=' | |
spawn adb -s' | |
body='shell | |
expect "#" | |
set cmd "cd /data/local/tmp/; LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/tvm_rpc server --tracker=IP_ADDRESS:PORT --key=\"your_key_here\"" | |
send $cmd | |
send "\r" | |
interact | |
' | |
expect -c "$preamble $device_id $body" | |
} | |
while true | |
do | |
run $1 | |
echo "RPC server died; restarting..." >&2 | |
sleep 20 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment