eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.32k stars 2.08k forks source link

Add support for automatic verticle redeployment in HA mode on CTRL-C or kill SIGTERM #1377

Open frank-montyne opened 8 years ago

frank-montyne commented 8 years ago

The HA mode the documentation states the following: "Please note that cleanly closing a Vert.x instance will not cause failover to occur, e.g.CTRL-C or kill -SIGINT"

Can this behavior become a user setting allowing to choose if CTRL-C or kill -SIGINT induces a failover or not?

I have the following use case: At some point in time I want to do maintenance on my Vert.x nodes by taking them offline in a round robin fashion. I am running a verticle that is receiving messages on the event bus that are being storied in an ElasticSearch database using bulk inserts. These bulk inserts run in a separate thread that needs to be stopped cleanly otherwise I run the risk that some events will not be stored. Since executing kill -SIGTERM simply kills the process my custom shutdown hook for finalizing the bulk inserts is not called introducing the risk of data loss.

pmlopes commented 8 years ago

SIGINT means that the interactive user requested the application to be interrupted (get back to the prompt) This is clearly a user/script originated signal asking the process to quit (since it is a SIGINT the process is not required to quit and can even ignore it).

see: https://www.cons.org/cracauer/sigint.html

With this in mind, this clearly does not qualify as an system crash to trigger a HA redeploy.

I'd suggest to implement a proper clean method like, register to a eventbus address and once a message is received save your log and initialize the vertx.close() call, this way you're guaranteed that data is not abruptly lost or process killed due to timeout...