Skip to content

Instantly share code, notes, and snippets.

@csullivan
Created September 28, 2021 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csullivan/2ceb047e26bbb2bb39fbedd91fb91150 to your computer and use it in GitHub Desktop.
Save csullivan/2ceb047e26bbb2bb39fbedd91fb91150 to your computer and use it in GitHub Desktop.
Expect script to restart TVM RPC server on Android after crash
#!/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