Handling Ctrl-C Signal in a verticle

650 views
Skip to first unread message

Sumanta Sen

unread,
Aug 17, 2015, 3:11:21 AM8/17/15
to vert.x
Hi All,

We have 5 instances of verticle running as part of our application.

To stop the application, we are killing the java process using "kill -9 " command.

Is there a way to catch the signal inside the verticle?

Thanks.

Tim Fox

unread,
Aug 17, 2015, 3:22:06 AM8/17/15
to ve...@googlegroups.com
It's not possible to catch a kill -9. The OS doesn't give the process a chance to do this.


Thanks.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/e4038698-576f-496a-a5c9-3ef0a6216e9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sumanta Sen

unread,
Aug 17, 2015, 3:30:52 AM8/17/15
to vert.x

Tim,

Is there any better way of gracefully stopping these processes?

Thanks

Tim Fox

unread,
Aug 17, 2015, 3:37:52 AM8/17/15
to ve...@googlegroups.com
On 17/08/15 08:30, Sumanta Sen wrote:

Tim,

Is there any better way of gracefully stopping these processes?

You can send a SIGINT (usually CTRL-C does this) to shut it down gracefully.

Sumanta Sen

unread,
Aug 17, 2015, 3:41:20 AM8/17/15
to vert.x
Can you please refer to any sample code where this signal can be caught by verticle instance?

Thanks

Tim Fox

unread,
Aug 17, 2015, 3:50:13 AM8/17/15
to ve...@googlegroups.com
Why do you want to catch it?

Sumanta Sen

unread,
Aug 17, 2015, 4:09:24 AM8/17/15
to vert.x
We donot want stop all instance immediately.

We need to do certain parameter validation inside the application before killing the instance.

Tim Fox

unread,
Aug 17, 2015, 4:13:27 AM8/17/15
to ve...@googlegroups.com
Graceful shutdown does not "stop all instances immediately".

It calls the stop() methods of your verticles in child-first order, so if you if you need to do any validation before undeploying them you can do it in there.

Tim Fox

unread,
Aug 18, 2015, 5:22:27 AM8/18/15
to ve...@googlegroups.com
You can, of course, provide your own shutdown hook just like you would in any Java program (that's not specific to Vert.x) but it shouldn't be necessary in most cases.
Reply all
Reply to author
Forward
0 new messages