Running multiple Gradle commands in parallel on Linux shell -
please note: although 2 primary techs in question spring boot , gradle, think linux/command-line question @ heart, involving fore- , background processes!
i'm trying spring boot app run in hot swap ("dev") mode via gradle. after reading this interesting dzone article, takes few easy steps:
- make minor tweaks
build.gradle
- open terminal , run
./gradlew build --continuous
; wait finish/start up - open second terminal , run
./gradlew bootrun
- voila! can make code changes jvm classes , hot-recompiled on fly , picked spring boot app. hooray fast dev cycles!
however i'm trying improve upon wee bit. i'd run single shell script (e.g. rundevmode.sh
) , have both these processes spun me in correct order. tried:
./gradlew build --continuous & ./gradlew bootrun && fg
i put inside rundevmode.sh
, ran sh rundevmode.sh
. see both tasks starting without errors, when make code changes java classes, don't see changes picked up. ideas i'm going awry?
the successful runs run in separate terminals, perhaps unsuccessful runs fighting on same resources, (whatever might be). try using separate subshells:
# 1) launch 1st program in background subshell. # 2) sleep 30 seconds # 3) launch 2nd program in background subshell. # 4) foreground '3)'. (it didn't need in background.) ( ./gradlew build --continuous & ) ; sleep 30s && ( ./gradlew bootrun & ) ; fg
commands in parenthesis launched in subshell. in open terminal, suppose run sh
or bash
or shell , assign variable, type exit
, , try use variable:
$ ps1='~> ' dash # assign temporary prompt, run subshell ~> foo=bar ~> echo :$foo: :bar: ~> exit $ echo :$foo: ::
above '$' main shell prompt, (don't type that), , '-> ' subshell's prompt, (don't type either). colons ('::') aren't commands, show when $foo unset or empty. variable assignments cannot leave subshell, (nor can cross on concurrent subshell).
see "compound commands" in man bash
.
Comments
Post a Comment