You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 runningsudo 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 withRestart=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.
pause()
) instead of exiting it withexit(0)
aftershutdown -h now
above.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)
The text was updated successfully, but these errors were encountered: