#!/usr/bin/env bash
# Will attempt to execute a corda node within all subdirectories in the current working directory.
# TODO: Use screens or separate windows when starting instances.

set -euo pipefail
trap 'kill $(jobs -p)' EXIT
export CAPSULE_CACHE_DIR=cache

function runNode {
    pushd $1
    ( java -jar JAR_NAME )&
    popd
}

for dir in `ls`; do
    if [ -d $dir ]; then
        runNode $dir
    fi
done

read -p 'Any key to exit'
kill $(jobs -p)
