snapp_cli icon indicating copy to clipboard operation
snapp_cli copied to clipboard

Stop the app on the remote device when the user stops it from host machine

Open berkobob opened this issue 1 year ago • 10 comments

I love your snapp_cli app, thank you. One issue, when I stop the app from my PC, the debugger disconnects but the app continues to run on the RPi. Is there a way to cleanly stop the app running? Thanks.

berkobob avatar Jan 19 '24 12:01 berkobob

Hey @berkobob Happy to hear it is useful for you.

I will investigate about this.

I guess it's not possible from the flutter side, but maybe we can do a trick and kill the app by app ID.

I will let you know about possibilities.

payam-zahedi avatar Jan 19 '24 13:01 payam-zahedi

Any luck with this? I'm having to reboot the pi each time because I don't know the name (or number) of the process to kill. Thanks!

berkobob avatar Jan 24 '24 10:01 berkobob

Unfortunately, I didn't manage to check this issue.

you can find the app ID with this command

app_pid=$(pgrep -f "$app_command")

app_command=/tmp/\${appName}/build/linux/arm64/debug/bundle/\${appName}

If you want to work on this you can add this line in your custom_devices.json file after the line we lauch the app

payam-zahedi avatar Jan 24 '24 10:01 payam-zahedi

That works, thank you.

berkobob avatar Jan 24 '24 11:01 berkobob

@berkobob Can you share the final solution that you use?

I want add a update for it

payam-zahedi avatar Apr 17 '24 09:04 payam-zahedi

I find the process ID as you showed me and then kill the process.

berkobob avatar Apr 17 '24 11:04 berkobob

Alright,

If I get it right, you did this process manually right?

You did not change the custom_devices.json file

payam-zahedi avatar Apr 17 '24 15:04 payam-zahedi

No, I didn't.

berkobob avatar Apr 17 '24 15:04 berkobob

Thanks @berkobob

payam-zahedi avatar Apr 17 '24 15:04 payam-zahedi

I think I may have found a solution. Adding the -tt flag to the ssh command forces the allocation of a PTY (pseudoterminal). This seems to ensure that the flutter-pi process on the target device receives a SIGHUP signal when disconnecting, which should allow it to shut down properly.

payam-zahedi avatar Nov 04 '24 15:11 payam-zahedi