@@ -174,6 +174,23 @@ case "`uname -s`" in
174
174
;;
175
175
esac
176
176
177
+ clean_heap_dump_files ()
178
+ {
179
+ if [ " $CASSANDRA_HEAPDUMP_KEEP_NEWEST_N_FILES " != " " ] && \
180
+ [ " $CASSANDRA_HEAPDUMP_KEEP_NEWEST_N_FILES " -ge 0 ] && \
181
+ [ -d " $CASSANDRA_HEAPDUMP_DIR " ]; then
182
+ # find all files under CASSANDRA_HEAPDUMP_DIR,
183
+ # sort by last modification date descending,
184
+ # print those, that need to be removed
185
+ ls -pt1 " $CASSANDRA_HEAPDUMP_DIR " | grep -v / | \
186
+ grep " ^cassandra-.*-pid.*[.]hprof$" | \
187
+ awk " { if (NR > $CASSANDRA_HEAPDUMP_KEEP_NEWEST_N_FILES ) print \$ 0}" | \
188
+ while IFS= read -r file; do
189
+ rm -f " $CASSANDRA_HEAPDUMP_DIR /$file "
190
+ done
191
+ fi
192
+ }
193
+
177
194
launch_service ()
178
195
{
179
196
pidpath=" $1 "
@@ -188,6 +205,8 @@ launch_service()
188
205
cassandra_parms=" $cassandra_parms -Dcassandra-pidfile=$pidpath "
189
206
fi
190
207
208
+ clean_heap_dump_files
209
+
191
210
# The cassandra-foreground option will tell CassandraDaemon not
192
211
# to close stdout/stderr, but it's up to us not to background.
193
212
if [ " x$foreground " != " x" ]; then
@@ -247,6 +266,8 @@ while true; do
247
266
;;
248
267
-H)
249
268
properties=" $properties -XX:HeapDumpPath=$2 "
269
+ # disable automatic heap dump files management as HeapDumpPath was overridden
270
+ CASSANDRA_HEAPDUMP_KEEP_NEWEST_N_FILES=-1
250
271
shift 2
251
272
;;
252
273
-E)
0 commit comments