deploy: try to restart adb server on dev timeout

This commit is contained in:
timoxa0 2024-10-22 15:58:31 +05:00
parent 43ef704a32
commit 01cab85f6b

View file

@ -230,7 +230,24 @@ var deployCmd = &cobra.Command{
for i := 0; i <= 120; i++ {
if i == 120 {
ofoxSpinner.Stop()
logger.Error("Recovery device timeout")
logger.Warn("Recovery device timeout")
logger.Info("Trying to restart adb server")
err := adbc.KillServer();
if err != nil {
logger.Error("Failed to kill server")
os.Exit(173);
}
err = adbc.StartServer();
if err != nil {
logger.Error("Failed to start server")
os.Exit(173);
}
adbd = adbc.Device(adb.DeviceWithSerial(serail));
if s, _ := adbd.State(); s == adb.StateRecovery {
logger.Info("Device found")
break
}
logger.Error("Device not found")
os.Exit(173)
}
if s, _ := adbd.State(); s == adb.StateRecovery {
@ -276,7 +293,24 @@ var deployCmd = &cobra.Command{
for i := 0; i <= 120; i++ {
if i == 120 {
ofoxSpinner.Stop()
logger.Error("Recovery device timeout")
logger.Warn("Recovery device timeout")
logger.Info("Trying to restart adb server")
err := adbc.KillServer();
if err != nil {
logger.Error("Failed to kill server")
os.Exit(173);
}
err = adbc.StartServer();
if err != nil {
logger.Error("Failed to start server")
os.Exit(173);
}
adbd = adbc.Device(adb.DeviceWithSerial(serail));
if s, _ := adbd.State(); s == adb.StateRecovery {
logger.Info("Device found")
break
}
logger.Error("Device not found")
os.Exit(173)
}
if s, _ := adbd.State(); s == adb.StateRecovery {
@ -284,7 +318,8 @@ var deployCmd = &cobra.Command{
break
}
time.Sleep(time.Second)
}
}
port, err := utils.GetFreePort()
if err != nil {