hensm / fx_cast

Chromecast Web Sender SDK implementation for Firefox
https://hensm.github.io/fx_cast/
MIT License
1.87k stars 63 forks source link

Wiki: Add RestartSec=15s to Systemd service script #238

Closed Xaldew closed 1 year ago

Xaldew commented 1 year ago

OS version: Ubuntu 22.04 Browser version: Firefox Extension version: N/A Bridge version: N/A

Description

Hello!

Thanks a lot for this useful extension, I'm personally finding it extremely useful! However, I noticed that my machine started taking forever to shutdown for some reason, when I investigated it, it turned out to be the fx_cast daemon process that was holding up the clean-shutdown process (for up to 1.5min, when it is force terminated).

I'm not 100% sure why yet, but I suspect that the program is lightweight enough that with Restart=always the service starts up again fast enough all the time, preventing a clean exit. One easy workaround would be to add e.g., RestartSec=15s, to delay the startup slightly and allow the shutdown process to finish before a new instance gets started up, i.e., something like this:

[Unit]
Description=fx_cast daemon

[Service]
User=fx_cast
ExecStart=/opt/fx_cast/fx_cast_bridge -d
Restart=always
RestartSec=15s

[Install]
WantedBy=multi-user.target

That said, I'm sure that someone who knows Systemd better than me can think of a better solution than this.

hensm commented 1 year ago

This will probably be the same as #230. There's an build that fixes this in the issue comments, but I'll upload some proper bridge builds to the v0.3.1 release soon.

Xaldew commented 1 year ago

Ah, you're probably right. Additionally, it seems like this 'fix' only works occasionally. It is apparently still locking up the shutdown every so often. I'll try force uninstalling and reinstalling as mentioned in #230 to see if that changes things

Xaldew commented 1 year ago

Just another minor update: A fresh install did not fix things, and I haven't really had time to dig into the Node.js ecosystem to try to build things from scratch. However, one workaround that does work, is adding KillSignal=SIGKILL (default is SIGTERM) to the service file.

hensm commented 1 year ago

You need a fresh install with the build linked here. The KillSignal change makes sense, since the issue is the bridge isn't exiting itself after handling SIGTERM, so it hangs until systemd sends SIGKILL after the timeout.

Xaldew commented 1 year ago

Ahh, not sure how I missed that, yes that build does indeed fix it even for me, sorry for the noise!