clicon / clixon-controller

Clixon network controller
Apache License 2.0
14 stars 5 forks source link

Python API server left running if backend is brutally killed #51

Closed krihal closed 8 months ago

krihal commented 11 months ago

Should be handled in some way, either by PyAPI or backend.

debian@khn-dev:~/Git/clixon-pyapi$ ps aux | grep clixon_server.py
clicon    290040  0.0  0.2 103368 23340 ?        Sl   07:25   0:00 python3 /usr/local/bin/clixon_server.py -f /usr/local/etc/controller.xml -F
debian    304054  0.0  0.0   3884  1884 pts/6    S+   07:30   0:00 grep clixon_server.py
debian@khn-dev:~/Git/clixon-pyapi$ ps aux | grep backend
root      303504  0.0  0.0   5736  4672 ?        Ss   07:30   0:00 clixon_backend -f /usr/local/etc/controller.xml
debian    304453  0.0  0.0   3876  1920 pts/6    S+   07:30   0:00 grep backend
debian@khn-dev:~/Git/clixon-pyapi$ sudo kill -9 303504
debian@khn-dev:~/Git/clixon-pyapi$ ps aux | grep clixon_server.py
clicon    290040  0.0  0.2 103368 23340 ?        Sl   07:25   0:00 python3 /usr/local/bin/clixon_server.py -f /usr/local/etc/controller.xml -F
debian    304898  0.0  0.0   3884  1872 pts/6    S+   07:30   0:00 grep clixon_server.py
debian@khn-dev:~/Git/clixon-pyapi$
olofhagsand commented 11 months ago

If you kill the parent process, the pyapi should get a closed socket or a message with length 0. If this is detected, the pyapi should close. This seems to work fine in a c-service:

olof@alarik> ps jax --sort=uid,-ppid,+pid | grep -v grep| grep clixon
   3401 1798369 1798369 1798369 ?             -1 Ss       0   0:01 clixon_backend -s startup -f /var/tmp/./test-c-service.sh/controller.xml -D 0
1798369 1798370 1798369 1798369 ?             -1 S     1001   0:00 /usr/local/bin/clixon_controller_service -f /var/tmp/./test-c-service.sh/controller.xml -D 1 -lf/tmp/service.log
olof@alarik> sudo kill -9 1798369
olof@alarik> ps jax --sort=uid,-ppid,+pid | grep -v grep| grep clixon
olof@alarik> 

Assign to @krihal

krihal commented 8 months ago

Fixed: https://github.com/clicon/clixon-pyapi/commit/9d5ffa78409e9d789db52996ef048f1accdf335a