Skip to content

Commit

Permalink
Ensure CrateDB process gets terminated on cr8 sigterm
Browse files Browse the repository at this point in the history
The CrateDB process leaked if `cr8 run-crate` was killed via a SIGTERM.
For example, in a bash script like:

    cr8 run-crate latest-nightly &
    N1=$!
    while ! crash --hosts localhost:4200 -c "select 1" > /dev/null 2>&1; do
        sleep 1
    done
    jps
    kill $N1
    jps
  • Loading branch information
mfussenegger committed Apr 8, 2024
1 parent 7531dde commit cc4cef8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cr8/run_crate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
import socket
import ssl
import platform
import signal
from datetime import datetime
from hashlib import sha1
from pathlib import Path
from functools import partial
from itertools import cycle
from typing import Optional, Dict, Any, List, NamedTuple
from typing import Dict, Any, List, NamedTuple
from urllib.request import urlopen

from cr8.java_magic import find_java_home
Expand Down Expand Up @@ -790,6 +791,12 @@ def run_crate(
keep_data,
java_magic=not disable_java_magic,
) as n:

def stop(signum, frame):
n.stop()
sys.exit(0)

signal.signal(signal.SIGTERM, stop)
try:
n.start()
n.process.wait()
Expand Down

0 comments on commit cc4cef8

Please sign in to comment.