embedded-redis icon indicating copy to clipboard operation
embedded-redis copied to clipboard

Enable force stop

Open artkonr opened this issue 3 years ago • 2 comments

Hey team,

In our project, we're using embedded Redis instances with fixed ports and we occasionally encounter situations, when the Redis instance is not terminated properly leaving the port busy after the JVM is shut down, forcing us in turn to do kill -9.

With this PR I'd like to introduce a builder flag for standalone, sentinel and cluster that enables force-stopping of the instance by passing a SIGKILL via Process#destroyForcibly() instead a graceful SIGTERM. The new config would be enabled solely on Java side like this:

Redis redis = RedisServer.builder()
    .onShutdownForceStop(true)
    .build();

Apart from this change, I've also taken upon myself the liberty of doing a bit of a clean-up:

  • fixed maven warnings (absent compiler version and use of <prerequisites>)
  • made a few tweaks to the test classes (replacing deprecated Jedis API calls and silencing other non-critical warnings).

All changes introduced go in separate commits, let me know if you want to go with some of them and not accept others or to squash them into bigger change sets.

artkonr avatar Sep 28 '22 14:09 artkonr

I like this idea so I built this into my fork of the project.

codemonstur avatar Nov 09 '22 13:11 codemonstur

This fork saves my day!

nickngn avatar Apr 04 '23 01:04 nickngn