delfick / photons

Python3.6+ asyncio framework for interacting with LIFX devices
https://photons.delfick.com
MIT License
73 stars 6 forks source link

RFE: Need to way to tell Interactor to stop gracefully #41

Closed Djelibeybi closed 3 years ago

Djelibeybi commented 3 years ago

Currently, the only way to stop lifx lan:interactor is by killing the process, which makes systemd rather cross about the whole situation and renders Restart=on-failure a bit hit and miss.

It would be good if the status command took an optional boolean parameter shutdown and if that parameter is true, Interactor would shut itself down.

I'd add this myself, but I don't know how to tell Interactor to end. 😂

delfick commented 3 years ago

yeah, that should be easy. I'll do that a bit later.

Sigterm is graceful but it causes the app to exit with status 1

On Fri, 8 Jan 2021, 12:25 pm Joshua, notifications@github.com wrote:

The only way i know how to stop it gracefully is ctl+c When you start it manually. Not sure if there's any other way implemented at the moment

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/delfick/photons/issues/41#issuecomment-756487667, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2V5NSCPWZDLGQT7S2GLDSYZNHXANCNFSM4VZYZNNQ .

delfick commented 3 years ago

I was wrong when I said "easy". sigh

delfick commented 3 years ago

Ok, fixed in #41

Specifically, https://github.com/delfick/photons/commit/2da982f548113c3950895cbb3532c9cb86948221

SIGTERM will no longer make the interactor (or the arranger) exit with status 1.

I've released Version 0.8.3 of interactor, and building the docker container now in https://github.com/delfick/photons/runs/2210707217

delfick commented 3 years ago

weird, I'm gonna remake the docker image with the update I made yesterday https://github.com/delfick/photons/runs/2274983632?check_suite_focus=true

can you make it have the latest docker image when it's done and try again?

On Tue, Apr 6, 2021 at 1:36 PM Avi Miller @.***> wrote:

Sending a SIGTERM to the Interactor process still results in an exit code of 1. This is the error output after I sent a kill -TERM :

13:34:42 ERROR photons_app.options_spec.photons_app_spec "The application itself was stopped" Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/photons_app/option_spec/photons_app_spec.py", line 167, in cleanup await cleaner() File "/usr/local/lib/python3.9/site-packages/photons_control/device_finder.py", line 900, in finish async with hp.TaskHolder( File "/usr/local/lib/python3.9/site-packages/photons_app/helpers.py", line 89, in aenter return await self.start() File @./3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 182, in aexit await self.gen.anext() File "/usr/local/lib/python3.9/site-packages/photons_app/runner.py", line 70, in run loop.run_until_complete(waiter) File @./3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/usr/local/lib/python3.9/site-packages/photons_app/runner.py", line 62, in wait await graceful_future File "/usr/local/lib/python3.9/site-packages/interactor/addon.py", line 36, in interactor await Server(final_future).serve( File "/usr/local/lib/python3.9/site-packages/whirlwind/server.py", line 28, in serve await self.final_future photons_app.errors.ApplicationStopped: "The application itself was stopped" 13:34:42 ERROR photons_app.options_spec.photons_app_spec "The application itself was stopped" Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/photons_app/option_spec/photons_app_spec.py", line 167, in cleanup await cleaner() File "/usr/local/lib/python3.9/site-packages/interactor/commander/animations.py", line 142, in stop return await self.action("stop", "stopping", identities) File "/usr/local/lib/python3.9/site-packages/interactor/commander/animations.py", line 180, in action async with hp.TaskHolder(self.final_future, name=f"Animations::action({method})[ts]") as ts: File "/usr/local/lib/python3.9/site-packages/photons_app/helpers.py", line 89, in aenter return await self.start() File @./3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 182, in aexit await self.gen.anext() File "/usr/local/lib/python3.9/site-packages/photons_app/runner.py", line 70, in run loop.run_until_complete(waiter) File @./3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/usr/local/lib/python3.9/site-packages/photons_app/runner.py", line 62, in wait await graceful_future File "/usr/local/lib/python3.9/site-packages/interactor/addon.py", line 36, in interactor await Server(final_future).serve( File "/usr/local/lib/python3.9/site-packages/whirlwind/server.py", line 28, in serve await self.final_future photons_app.errors.ApplicationStopped: "The application itself was stopped" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Something went wrong! -- ApplicationStopped "The application itself was stopped"

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/delfick/photons/issues/41#issuecomment-813797452, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2V5NWTOWQEXBP6TL7JCTTHJ6SRANCNFSM4VZYZNNQ .

Djelibeybi commented 3 years ago

I deleted my comment because I was indeed testing an older build instead of the latest code. Once I used the new version, it worked as expected.

delfick commented 3 years ago

hahahahaha

On Tue, 6 Apr 2021, 1:57 pm Avi Miller, @.***> wrote:

I deleted my comment because I was indeed testing an older build instead of the latest code. Once I used the new version, it worked as expected.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/delfick/photons/issues/41#issuecomment-813803446, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2V5NYSLULTQKF53WEJYTTHKBBXANCNFSM4VZYZNNQ .