diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a19e5932a..0e5cb0abe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Increase default etcd lease TTL to 10s and run keepalive earlier [#847](https://github.com/cloudamqp/lavinmq/pull/847) - Don't remove consumers from queue before all data is sent to client. It may cause a segmentation fault because a unmapped message segment is accessed. [#850](https://github.com/cloudamqp/lavinmq/pull/850) +### Changed + +- Exit with status 1 if lost leadership so that LavinMQ is restarted by systemd [#846](https://github.com/cloudamqp/lavinmq/pull/846) + ## [2.0.1] - 2024-11-13 ### Fixed diff --git a/src/lavinmq/launcher.cr b/src/lavinmq/launcher.cr index b6c888989c..3873d391d3 100644 --- a/src/lavinmq/launcher.cr +++ b/src/lavinmq/launcher.cr @@ -45,8 +45,10 @@ module LavinMQ if lease = @lease select when lease.receive? + break unless @running Log.warn { "Lost leadership lease" } - break + stop + exit 1 when timeout(30.seconds) @data_dir_lock.try &.poll GC.collect @@ -57,7 +59,6 @@ module LavinMQ GC.collect end end - stop end def stop