Skip to content

Commit 330c5a0

Browse files
authored
Some polish on the new loadup scripts - dribble files and lock overrides (#2157)
Three changes to loadup scripts: 1) dribble files are now copied from the workdir into loadups if loadup completes successfully, 2) if the lock preventing simultaneous runs is already set when loadup starts, it now asks the user if they want to override the lock or to exit (previously it just exited), 3) there is now a --override flag that will automatically override the lock without asking the user. Man page updated accordingly.
1 parent 2499b35 commit 330c5a0

File tree

6 files changed

+84
-21
lines changed

6 files changed

+84
-21
lines changed

internal/loadups/man-page/loadup.1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ The target files are copied from this work directory to the loadups
103103
directory if the loadup is successful.
104104
Each stage of the loadup also creates a dribble file containing the
105105
terminal output from within the Medley environment.
106-
These dribble files are not copied to the loadups directory, but remain
107-
available in the work directory after the loadup completes.
106+
These dribble files are also copied to the loadups directory, but also
107+
remain available in the work directory after the loadup completes.
108108
.PP
109109
Only one instance (per <MEDLEIDIR>) of loadup can be run at a time.
110-
(The lock file is in the work directory and is named
111-
\f[B]\f[BI]lock\f[B]\f[R].
112-
It can be removed in case of an uncontrolled failure of the loadup
113-
procedure.)
110+
There is lock file to prevent simultaneous loadups in the work directory
111+
(named \f[B]\f[BI]lock\f[B]\f[R]) that can be manually removed.
112+
The lock can also be automatically overridden (see the \[en]override
113+
flag below).
114+
Alternatively, if a lock is encountered at run time, the user will be
115+
asked to choose whether to override or simply exit the loadup.
114116
.PP
115117
Note: \f[B]MEDLEYDIR\f[R] is an environment variable set by the loadup
116118
script.
@@ -253,6 +255,12 @@ Synonym for \[lq]\[en]target apps\[rq]
253255
\f[B]-a-, --apps-, -apps-, -5-\f[R]
254256
Synonym for \[lq]\[en]target apps\[rq]
255257
.TP
258+
\f[B]-ov, --override, -override\f[R]
259+
Automatically override the lock that prevents two loadups from running
260+
simultaneously.
261+
If this flag is not set and an active lock is encountered, the user will
262+
be asked to choose whether to override or exit.
263+
.TP
256264
\f[B]-nc, --nocopy, -nocopy\f[R]
257265
Run the specified loadups, but do not copy results into loadups
258266
directory.

internal/loadups/man-page/loadup.1.gz

162 Bytes
Binary file not shown.

internal/loadups/man-page/loadup.1.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ The two independent stages that can be run if the first 4 sequential stages comp
4848
>+ **DB:**: creates the *fuller.database* file. Fuller.database is a Mastercope database created by analyzing all of the source code included in full.sysout. (Stage 4) Fuller.database is copied into the loadups directory.
4949
5050

51-
Loadup does all of its work in a work directory (\<MEDLEYDIR>loadups/build). The target files are copied from this work directory to the loadups directory if the loadup is successful. Each stage of the loadup also creates a dribble file containing the terminal output from within the Medley environment. These dribble files are not copied to the loadups directory, but remain available in the work directory after the loadup completes.
51+
Loadup does all of its work in a work directory (\<MEDLEYDIR>loadups/build). The target files are copied from this work directory to the loadups directory if the loadup is successful. Each stage of the loadup also creates a dribble file containing the terminal output from within the Medley environment. These dribble files are also copied to the loadups directory, but also remain available in the work directory after the loadup completes.
5252

5353

54-
Only one instance (per \<MEDLEIDIR>) of loadup can be run at a time. (The lock file is in the work directory and is named ***lock***. It can be removed in case of an uncontrolled failure of the loadup procedure.)
54+
Only one instance (per \<MEDLEIDIR>) of loadup can be run at a time. There is lock file to prevent simultaneous loadups in the work directory (named ***lock***) that can be manually removed. The lock can also be automatically overridden (see the --override flag below). Alternatively, if a lock is encountered at run time, the user will be asked to choose whether to override or simply exit the loadup.
5555

5656
Note: **MEDLEYDIR** is an environment variable set by the loadup script. It is set to the top level directory of the Medley installation that contains the specific loadup script that
5757
is invoked after all symbolic links are resolved. In the standard global installation this will
@@ -120,6 +120,9 @@ OPTIONS
120120
**-a-, \-\-apps-, -apps-, -5-**
121121
: Synonym for "--target apps"
122122

123+
**-ov, \-\-override, -override**
124+
: Automatically override the lock that prevents two loadups from running simultaneously. If this flag is not set and an active lock is encountered, the user will be asked to choose whether to override or exit.
125+
123126
**-nc, \-\-nocopy, -nocopy**
124127
: Run the specified loadups, but do not copy results into loadups directory.
125128

internal/loadups/man-page/man_loadup.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ <h1>DESCRIPTION</h1>
7777
work directory to the loadups directory if the loadup is successful.
7878
Each stage of the loadup also creates a dribble file containing the
7979
terminal output from within the Medley environment. These dribble files
80-
are not copied to the loadups directory, but remain available in the
81-
work directory after the loadup completes.</p>
80+
are also copied to the loadups directory, but also remain available in
81+
the work directory after the loadup completes.</p>
8282
<p>Only one instance (per &lt;MEDLEIDIR&gt;) of loadup can be run at a
83-
time. (The lock file is in the work directory and is named
84-
<strong><em>lock</em></strong>. It can be removed in case of an
85-
uncontrolled failure of the loadup procedure.)</p>
83+
time. There is lock file to prevent simultaneous loadups in the work
84+
directory (named <strong><em>lock</em></strong>) that can be manually
85+
removed. The lock can also be automatically overridden (see the
86+
–override flag below). Alternatively, if a lock is encountered at run
87+
time, the user will be asked to choose whether to override or simply
88+
exit the loadup.</p>
8689
<p>Note: <strong>MEDLEYDIR</strong> is an environment variable set by
8790
the loadup script. It is set to the top level directory of the Medley
8891
installation that contains the specific loadup script that is invoked
@@ -194,6 +197,13 @@ <h1>OPTIONS</h1>
194197
<dd>
195198
<p>Synonym for “–target apps”</p>
196199
</dd>
200+
<dt><strong>-ov, --override, -override</strong></dt>
201+
<dd>
202+
<p>Automatically override the lock that prevents two loadups from
203+
running simultaneously. If this flag is not set and an active lock is
204+
encountered, the user will be asked to choose whether to override or
205+
exit.</p>
206+
</dd>
197207
<dt><strong>-nc, --nocopy, -nocopy</strong></dt>
198208
<dd>
199209
<p>Run the specified loadups, but do not copy results into loadups

scripts/loadups/loadup

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ main() {
1717
nocopy=false
1818
thinw=false
1919
thinl=false
20+
override_lock=false
2021
while [ "$#" -ne 0 ];
2122
do
2223
case "$1" in
@@ -144,6 +145,9 @@ main() {
144145
export MAIKODIR="${maikodir}"
145146
shift
146147
;;
148+
-ov | -override | --override)
149+
override_lock=true
150+
;;
147151
--noendmsg)
148152
noendmsg=true
149153
;;
@@ -251,7 +255,7 @@ main() {
251255

252256

253257
# check and set the run_lock
254-
check_run_lock
258+
check_run_lock "${override_lock}"
255259

256260
# if requested, thin the loadups and workdirs by eliminating all versioned (*.~[0-9]*~) files
257261
# from these directories
@@ -348,18 +352,24 @@ main() {
348352
then
349353
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/lisp.sysout "${LOADUP_OUTDIR}" \
350354
| sed -e "s#${MEDLEYDIR}/##g"
355+
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/lisp.dribble "${LOADUP_OUTDIR}" \
356+
| sed -e "s#${MEDLEYDIR}/##g"
351357
fi
352358

353359
if [ $start -le 3 ] && [ $end -ge 4 ]
354360
then
355361
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/full.sysout "${LOADUP_OUTDIR}" \
356362
| sed -e "s#${MEDLEYDIR}/##g"
363+
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/full.dribble "${LOADUP_OUTDIR}" \
364+
| sed -e "s#${MEDLEYDIR}/##g"
357365
fi
358366

359367
if [ $start -le 4 ] && [ $end -ge 5 ]
360368
then
361369
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/apps.sysout "${LOADUP_OUTDIR}" \
362370
| sed -e "s#${MEDLEYDIR}/##g"
371+
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/apps.dribble "${LOADUP_OUTDIR}" \
372+
| sed -e "s#${MEDLEYDIR}/##g"
363373
fi
364374

365375
if [ "${aux}" = true ]
@@ -368,12 +378,18 @@ main() {
368378
| sed -e "s#${MEDLEYDIR}/##g"
369379
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/exports.all "${LOADUP_OUTDIR}" \
370380
| sed -e "s#${MEDLEYDIR}/##g"
381+
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/whereis.dribble "${LOADUP_OUTDIR}" \
382+
| sed -e "s#${MEDLEYDIR}/##g"
383+
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/exports.dribble "${LOADUP_OUTDIR}" \
384+
| sed -e "s#${MEDLEYDIR}/##g"
371385
fi
372386

373387
if [ "${db}" = true ]
374388
then
375389
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/fuller.database "${LOADUP_OUTDIR}" \
376390
| sed -e "s#${MEDLEYDIR}/##g"
391+
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/fuller.dribble "${LOADUP_OUTDIR}" \
392+
| sed -e "s#${MEDLEYDIR}/##g"
377393
fi
378394

379395
fi

scripts/loadups/loadup-setup.sh

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,39 @@ process_maikodir() {
249249
export LOADUP_LOCKFILE="${LOADUP_WORKDIR}"/lock
250250

251251
check_run_lock() {
252-
if [ -e "${LOADUP_LOCKFILE}" ]
253-
then
254-
output_error_msg "Error: Another loadup is already running with PID $(cat "${LOADUP_LOCKFILE}")${EOL}Exiting."
255-
exit 1
256-
fi
257-
echo "$$" > "${LOADUP_LOCKFILE}"
258-
LOADUP_LOCK="$$"
252+
set +x
253+
if [ -e "${LOADUP_LOCKFILE}" ]
254+
then
255+
output_warn_msg "Warning: Another loadup is already running with PID $(cat "${LOADUP_LOCKFILE}")"
256+
if [ "${override_lock}" = true ]
257+
then
258+
output_warn_msg "Overriding lock preventing simultaneous loadups due to command line argument --override${EOL}Continuing."
259+
else
260+
loop_done=false
261+
while [ "${loop_done}" = "false" ]
262+
do
263+
output_warn_msg "Do you want to override the lock guarding against simultaneous loadups?"
264+
output_warn_msg "Answer [y, Y, n or N, default n] followed by RETURN"
265+
read resp
266+
if [ -z "${resp}" ]; then resp=n; fi
267+
case "${resp}" in
268+
n* | N* )
269+
output_error_msg "Ok. Exiting"
270+
exit 5
271+
;;
272+
y* | Y* )
273+
output_warn_msg "Ok. Overriding lock and continuing"
274+
loop_done=true
275+
;;
276+
* )
277+
output_warn_msg "Answer not one of Y, y, N, or n. Retry."
278+
;;
279+
esac
280+
done
281+
fi
282+
fi
283+
echo "$$" > "${LOADUP_LOCKFILE}"
284+
LOADUP_LOCK="$$"
259285
}
260286

261287
remove_run_lock() {

0 commit comments

Comments
 (0)