Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit pkill for exiting the barrier code #8

Open
jara001 opened this issue May 23, 2022 · 0 comments
Open

Omit pkill for exiting the barrier code #8

jara001 opened this issue May 23, 2022 · 0 comments

Comments

@jara001
Copy link
Member

jara001 commented May 23, 2022

This is not very nice, because it may kill unrelated websocats. More importantly, it seems that you consider only the case when the application is started by arrowhead scripts, but this may cause problems when starting the program as systemd optic_barrier.service.

When the program is started as a systemd service, which can be detected from environment variable, e.g. getenv("INVOCATION_ID"), you should simply exit by running sudo systemctl stop optic_barrier.service, or maybe restart instead of stop. Without that websocat might be restarted by systemd automatically, because the service is configured with Restart=always and there might be interesting race conditions.

When started by arrowhead scripts I'd set an environment variable and run pkill only if that variable is set.

P.S. When looking at this, I also noticed that we might want change the shutdown_handler(). My original (now partially outdated) comment:

I guess that the problem you're solving with this line is to prevent websocat restarting the program while the shutdown is in process. Maybe, you also want to close the websocket connection cleanly so that the backend does not have to wait for some timeout.

  • The first problem could be solved better by stopping the process (e.g. calling pause()) instead of exiting it with exit(0) after shutdown -h now above.
  • The second problem (clean close of websocket) can be solved by adding proper After=/Before= directives to the systemd service unit, which ensures that websocat is terminated before the network is shut down during power off.

Originally posted by @wentasah in #6 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant