Gracefully Exit Jina

In Python

If you use with scope to start a Flow, then all resources (including Pods of all kinds) of the Flow will be released after your move out from the scope.

If you use start() method to start the Flow, then you have to call close() to shut down the Flow when you don’t use it anymore.

In the Console

If you are running Jina locally (e.g. jina flow), you can Control-c or Command-c to terminate it at any time. All BasePod will receive this signal and shut down accordingly.

Container Pods and remote Pods sometimes take longer to shut down. When you open many replicas or many Pods, it may also take some time to release all resources.

Rule of thumb, for an individual Pod/Pea, when you see the following output from the console, then it is already shut down.

[email protected][I]:no update since 2020-04-23 20:31:10, will not save. If you really want to save it, call "touch()" before "save()" to force saving
[email protected][I]:executor says there is nothing to save
[email protected][I]:msg_sent: 0 bytes_sent: 0 KB msg_recv: 0 bytes_recv:0 KB
[email protected][I]:msg_sent: 0 bytes_sent: 0 KB msg_recv: 0 bytes_recv:0 KB
[email protected][S]:terminated

For Flow, when you see the following output from the console, then it is shutdown already.

[email protected][S]:terminated
[email protected][I]:msg_sent: 653 bytes_sent: 590 KB msg_recv: 326 bytes_recv:956 KB
[email protected][S]:terminated
[email protected][I]:msg_sent: 653 bytes_sent: 587 KB msg_recv: 326 bytes_recv:948 KB
[email protected][S]:terminated
[email protected][I]:msg_sent: 651 bytes_sent: 583 KB msg_recv: 325 bytes_recv:939 KB
[email protected][S]:terminated
[email protected][I]:msg_sent: 653 bytes_sent: 589 KB msg_recv: 326 bytes_recv:953 KB
[email protected][S]:terminated
[email protected][S]:flow is closed and all resources should be released already, current build level is EMPTY