Automating Taskman shutdown and restart during Linux reboot

59 views
Skip to first unread message

Benjamin Irwin

unread,
May 8, 2024, 11:04:40 AMMay 8
to Hardhats
Is there a method to automate the clean shutdown and restart of Taskman when a Linux system is rebooted. 

ivaldes

unread,
May 8, 2024, 1:49:43 PMMay 8
to Hardhats
I have some bash scripts vistastop.sh vistastart.sh that I created long ago in the Astronaut VistA variant distribution. You direct systemd or whichever flavor of linux you have to run these scripts on start or shutdown. 

-- Ignacio Valdes, MD, MS, ABPM, ABPN, CAM

 more vistastart.sh
#!/bin/bash
# vistastart
#!/bin/bash
cd `dirname $0`
if [ $EUID -eq 0 ]; then
  echo "Run as $vista_user, not as root."
  exit;
fi
rm -f ../tmp/*.mj[oe]
source /opt/astrovista/EHR/etc/env.astrovista
echo "vistastart gtm_dist: $gtm_dist, gtm_vista: $gtm_vista"
$gtm_dist/mupip journal -recover -backward $gtm_vista/journals/mumps.mjl
$gtm_dist/mupip rundown -region DEFAULT

rm -f $vista_path/globals/scratch.dat
rm -f $vista_path/globals/mumps.gld
echo "before GDE"

# Merged similar Astronaut install script stuff and the below about 20 lines wit
h Medsphere Systems Corp.
# instanceadd script with Astronaut variable modifications and a few changes.
# Per Gus, allocation count resulting in 2Gb and extension count 0 is better bec
ause you will fill
# up your database before you fill up your disk.
(
    umask 027
#$gtm_path/mumps -run ^GDE <<EOF
$gtm_path/mumps -run ^GDE > /dev/null 2>&1 <<EOF
CHANGE -SEGMENT DEFAULT -ACCESS_METHOD=BG -BLOCK_SIZE=4096 -ALLOCATION=500000 -E
XTENSION_COUNT=0 -GLOBAL_BUFFER_COUNT=4096 -LOCK_SPACE=400 -FILE=$vista_path/glo
bals/mumps.dat
CHANGE -REGION DEFAULT -RECORD_SIZE=4080 -KEY_SIZE=255 -JOURNAL=(BEFORE_IMAGE,FI
LE_NAME="$vista_path/journals/mumps.mjl") -DYNAMIC_SEGMENT=DEFAULT
TEMPLATE -SEGMENT -ACCESS_METHOD=BG -BLOCK_SIZE=4096 -ALLOCATION=1024 -EXTENSION
_COUNT=1024 -GLOBAL_BUFFER_COUNT=4096 -LOCK_SPACE=400
TEMPLATE -REGION -RECORD_SIZE=4080 -KEY_SIZE=255 -NOJOURNAL
ADD -SEGMENT SCRATCH -FILE=$vista_path/globals/scratch.dat
ADD -REGION SCRATCH -DYNAMIC_SEGMENT=SCRATCH
ADD -NAME TMP -REGION=SCRATCH
ADD -NAME TEMP -REGION=SCRATCH
ADD -NAME UTILITY -REGION=SCRATCH
TEMPLATE -REGION -RECORD_SIZE=4080 -KEY_SIZE=255 -JOURNAL=BEFORE_IMAGE
EXIT
EOF
)

# mumps doesn't exit non-zero even if something goes wrong in ^GDE, so look for
# the mumps.gld to determine success
[ -f "$vista_path/globals/mumps.gld" ] ||
exit_with_error "$vista_path/instanceadd.sh" "Unable to create global directory
file"

mv $vista_path/globals/mumps.dat $vista_path/globals/mumps.tmp
$gtm_path/mupip create
rm -f $vista_path/globals/mumps.dat
mv $vista_path/globals/mumps.tmp $vista_path/globals/mumps.dat

[ -f "$vista_path/globals/scratch.dat" ] ||
exit_with_error "$vista_path/instanceadd.sh" "Unable to create scratch.dat file"

chmod 760 $vista_path/globals/scratch.dat

#echo "before .1 zosf."
$gtm_dist/mumps -direct > /dev/null 2>&1 << EOF
SET ^%ZOSF("TMP")="$vista_path/bin/tmp"
h
EOF

$gtm_dist/mupip set -journal=enable,on,before,filename=$vista_path/journals/mump
s.mjl -region DEFAULT
#$gtm_dist/mupip set -journal="enable,on,before" -file $gtm_vista/globals/mumps.
dat

echo "before box:volume"
# Set box:volume pair.
#$gtm_path/mumps -r ^VWSTART <<EOF
$gtm_path/mumps -r ^VWSTART > /dev/null 2>&1 <<EOF
XUTIME
EOF

#$gtm_path/mumps -direct  > /dev/null 2>&1 <<EOF
$gtm_path/mumps -direct <<EOF
S DUZ=1
D RESTART^ZTMB
y
EOF

# Engage in note imaging.
#$gtm_path/mumps -direct <<EOF
#S DUZ=1
#D ASTROIMG^TMGRPC1D
#
#h
#EOF

# Give the path for the console.
#$gtm_path/mumps -direct <<EOF
#S DUZ=1 D ^XUP,SETUP^TMGKERN3
#$vista_path/bin/run.sh
#
#h
#EOF

find $gtm_vista/globals -iname mumps.mjl_\* -mtime +3 -exec rm -v {} \;
echo "`date` $tmp_date Server start." >> $vista_path/log/vista_server.log

more vistastop.sh does a clean shutdown of VistA
#!/bin/bash
#vistastop
#!/bin/bash
cd `dirname $0`
echo "pwd: `pwd`"
source /opt/astrovista/EHR/etc/env.astrovista
cd $vista_path/bin
./run.sh STOP^ZTMKU <<EOF
y
y
h
EOF
sleep 1
ps -ef | grep mumps | grep -v grep | awk '{print $2}' | xargs kill 2>/dev/null
echo "`date` $tmp_date Server stop." >> $vista_path/log/vista_server.log

Benjamin Irwin

unread,
May 8, 2024, 2:46:19 PMMay 8
to Hardhats
Ignacio,
I think that contains all the pieces that I needed.

It would be nice not to have to perform the following two lines in any script, especially a systemd script.
sleep 1
ps -ef | grep mumps | grep -v grep | awk '{print $2}' | xargs kill 2>/dev/null


Thanks,
Ben

Sam Habiel

unread,
May 8, 2024, 10:26:19 PMMay 8
to hard...@googlegroups.com

Look for the SystemD section.

DO NOT USE RESTART^ZTMB. If starting a system, the only correct way to do it is [START]^ZTMB. RESTART does not clear state from a previous boot for a new start. Its only use is to start Taskman after it has been stopped (e.g. for a KIDS install), not for a new boot. Want to know the details? Read https://vivian.worldvista.org/dox/Routine_ZTM0_source.html.

Taskman can also be stopped non-interactively via these two calls:
D GROUP^ZTMKU("SSUB(NODE)")
D GROUP^ZTMKU("SMAN(NODE)")

--Sam

--
--
http://groups.google.com/group/Hardhats
To unsubscribe, send email to Hardhats+u...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Hardhats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hardhats+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hardhats/6df4c666-4784-423d-b83e-3ce0864e462bn%40googlegroups.com.

Benjamin Irwin

unread,
May 9, 2024, 3:07:24 AMMay 9
to Hardhats
More great stuff.  Thanks Sam.
Reply all
Reply to author
Forward
0 new messages