Skip to content

Implement "attach" command and graceful exiting #407

Description

@yarikoptic

The target is to implement (mecha)babs support for monitoring entire subject processing job script, so we could do smth like (expressing)

diff --git a/code/participant_job.sh b/code/participant_job.sh
index a49142d..c071ce2 100755
--- a/code/participant_job.sh
+++ b/code/participant_job.sh
@@ -6,6 +6,9 @@
 
 #SBATCH --time=24:00:00
 
+DUCT_PREFIX="logs/duct_${subid}_" con-duct attach &
+duct_pid=$!
+
 # shellcheck disable=SC1091
 source /dartfs/rc/lab/D/DBIC/DBIC/CON/asmacdo/mechababs/.venv/bin/activate
 
@@ -109,7 +112,6 @@ if [ ! -L "${CONTAINER_JOB}" ]; then
   exit 1
 fi
 
-export DUCT_PREFIX="logs/duct_${subid}_"
 
 # Step 1: Run BIDS app via containers-run
 datalad containers-run \
@@ -156,4 +158,7 @@ echo '# Push the branch with provenance records:'
 # shellcheck disable=SC2154
 flock "${DSLOCKFILE}" git push outputstore "${BRANCH}"
 
-echo SUCCESS
\ No newline at end of file
+
+kill "$duct_pid"  # inform to gracefully exit
+
+echo SUCCESS

docstring for attach would tell user to use kill potentially with specific signal (9 or INT) as to e.g. trigger killing without graceful shutdown which should happen on default kill which is TERM (15).

and attach will just monitor current session (like we have run --session=current) and not require a command to run

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions