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

The Redis Server does not stop upon application crash.

Open ChetanBhasin opened this issue 7 years ago • 4 comments

When the application crashes, the Redis server along with it does not stop. So if a test crashes, a person has to manually stop the process by killing it to free up the port.

ChetanBhasin avatar May 09 '17 13:05 ChetanBhasin

This is a problem with my project's unit tests also. We have to manually kill the redis server process after every test failure. (v0.6 on Windows)

dcrn avatar May 11 '17 08:05 dcrn

Just add a shutdown hook.

Runtime.getRuntime().addShutdownHook(new Thread() {
    public void run() { redis.stop(); }
});

maksymkovalenko avatar Jul 09 '17 00:07 maksymkovalenko

@maksymkovalenko this does not seem to work... could you please add more detailed example? where should this be added? in constructor?

ValeryIvanov avatar Nov 22 '17 09:11 ValeryIvanov

So, there is a way this could perhaps be made to work. Instead of launching redis directly, embedded-redis could use a wrapper script to kill redis when the JVM terminates... i.e. a wrapper script that does something like: https://stackoverflow.com/a/4054436/1589700

On the other hand, outside of testing, there could be valid reasons for keeping the process alive... for example if one were using redis to store application state and restarting the JVM to live self-"update" the application, you might be really annoyed if the embedded redis dies with the JVM

stephenc avatar Jun 26 '18 20:06 stephenc