srieger1 / digsinet

multiple twins (siblings) of a network topology (e.g., based on containerlab) with continuous data exchange
https://srieger1.github.io/digsinet/
5 stars 0 forks source link

Use ctrl+c for graceful shutdown #11

Closed Lachstec closed 4 months ago

Lachstec commented 6 months ago

Idea

Currently, you need to use the two python files digsinet-start.py and digsinet-stop.py to start and stop the application. It would be more ergonomic if normal ctl+c would gracefully shut down the application.

srieger1 commented 6 months ago

absolutely! ctrl+c can already be used to shutdown the controllers etc. If you rerun digsinet-start.py afterwards, contrainerlab will skip the creation and start of already running topologies (unless "--reconfigure" is not used as command line parameter). digsinet-stop.py was more or less initially developed to support stopping and cleaning up all running containerlab instances etc., but as digsinet-start.py and digsinet-stop.py share common code, it might be better to implement a command line parameter "--stop" or "--cleanup" etc. and use only one file? Also, regarding your idea maybe we should check that ctrl+c ensures a graceful shutdown, though I'm pretty confident this should be the case already, besides gNMI ops etc. possibly being interrupted?

srieger1 commented 6 months ago

update: just saw that you already started working on a branch that uses a single digsinet.py. Looks perfect! Go for it! 🚀

srieger1 commented 4 months ago

Now also at least partially implemented in main branch. Maybe we can close this issue for now?

Lachstec commented 4 months ago

Yup! Doing it with a custom SIGINT handler as it is done now is completely fine. I tried it with a similar approach before, but winded up with problems regarding containerlab. Calling sys.exit should free all used Resources and terminate all child processes.