On Sat, 09 May 2015 18:08:35 GMT, yawniek wrote:

On Tue, 05 May 2015 09:34:12 GMT, yawniek wrote:

is there a way to register code to be run on server shutdown?

e.g. i want to flush and close a specific log file from within a WorkerTask.

https://github.com/yannick/vibed-crash-example
here is an example, my questions:

a) why does it crash

Will comment on the GitHub issue when I get some more time to reproduce this.

b) why does it leak memory

Did you monitor if all Acks are getting sent? It could also just appear to be a memory leak, because the GC is relatively conservative about reusing memory. How much does the memory usage grow?

c) how to cleanly shutdown the worker task

The default handler for Ctrl+C currently simply stops all event loops. To perform additional work, you'd have to register your own signal handler. It could work similar to the default one (vibe.core.core.onSignal), but use a user defined signal instead. A separate shutdown thread could then wait on that signal and trigger any required cleanup work before shutting down the event loops using exitEventLoop(true).

Eventually, the default Ctrl+C behavior is planned to get improved. An idea would be to issue a Task.interrupt() call to every running task and then only forcefully terminate tasks that still keep running for more than a certain amount of time.