RejectedSoftware Forums

Sign up

shutdown task

i have a task that controls an external c library which has threads too.
when i press ctrl+c or shutdown via sigint i need to cleanly shutdown this task.
how can i get notified?

Re: shutdown task

On Tue, 06 Dec 2016 09:10:22 GMT, yawniek wrote:

i have a task that controls an external c library which has threads too.
when i press ctrl+c or shutdown via sigint i need to cleanly shutdown this task.
how can i get notified?

shared static ~this()
{
	writeln("Shutdown signal received");
}

Re: shutdown task

Am 06.12.2016 um 16:25 schrieb Alexey Kulentsov:

On Tue, 06 Dec 2016 09:10:22 GMT, yawniek wrote:

i have a task that controls an external c library which has threads too.
when i press ctrl+c or shutdown via sigint i need to cleanly shutdown this task.
how can i get notified?

shared static ~this()
{
	writeln("Shutdown signal received");
}

One thing to note is that at this point, the event loop will have
stopped already. You can start a new temporary one, though.

As an alternative, you can install your own signal handler for
SIGTERM/SIGINT using the signal function. From within the handler,
you could then send a message to your task (std.concurrency.send) to
trigger the shutdown, finally calling exitEventLoop.

Re: shutdown task

On Mon, 19 Dec 2016 12:31:19 +0100, Sönke Ludwig wrote:
...

One thing to note is that at this point, the event loop will have
stopped already. You can start a new temporary one, though.

As an alternative, you can install your own signal handler for
SIGTERM/SIGINT using the signal function. From within the handler,
you could then send a message to your task (std.concurrency.send) to
trigger the shutdown, finally calling exitEventLoop.

I think it need a topic in the documentation relating to stop the server.