Skip to content
Snippets Groups Projects
Commit a3cc33d7 authored by Dmitry Kalinkin's avatar Dmitry Kalinkin
Browse files

treewide: use `set -m` and `trap` to cleanup lingering processes

parent 1f0ca504
No related branches found
No related tags found
No related merge requests found
...@@ -72,6 +72,13 @@ rule backgrounds_ecal_backwards: ...@@ -72,6 +72,13 @@ rule backgrounds_ecal_backwards:
threads: workflow.cores threads: workflow.cores
shell: shell:
""" """
set -m # monitor mode to prevent lingering shells
cleanup() {{
echo Cleaning up
kill $WORKER_PID $SCHEDULER_PID
}}
trap cleanup EXIT
PORT=$RANDOM PORT=$RANDOM
dask scheduler --port $PORT & dask scheduler --port $PORT &
export DASK_SCHEDULER=localhost:$PORT export DASK_SCHEDULER=localhost:$PORT
...@@ -87,5 +94,4 @@ PROTON_BEAM_GAS_GEN=$(realpath {input.proton_beam_gas_gen}) \ ...@@ -87,5 +94,4 @@ PROTON_BEAM_GAS_GEN=$(realpath {input.proton_beam_gas_gen}) \
PROTON_BEAM_GAS_SIM=$(realpath {input.proton_beam_gas_sim}) \ PROTON_BEAM_GAS_SIM=$(realpath {input.proton_beam_gas_sim}) \
OUTPUT_DIR={output} \ OUTPUT_DIR={output} \
python {input.script} python {input.script}
kill $WORKER_PID $SCHEDULER_PID
""" """
...@@ -66,6 +66,7 @@ rule ecal_gaps: ...@@ -66,6 +66,7 @@ rule ecal_gaps:
threads: workflow.cores threads: workflow.cores
shell: shell:
""" """
set -m # monitor mode to prevent lingering shells
cleanup() {{ cleanup() {{
echo Cleaning up echo Cleaning up
kill $WORKER_PID $SCHEDULER_PID kill $WORKER_PID $SCHEDULER_PID
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment