Skip to content

Commit

Permalink
ENH Add flag to restartdaq
Browse files Browse the repository at this point in the history
  • Loading branch information
gadorlhiac committed Oct 25, 2024
1 parent b8e1c7d commit 028dab6
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions scripts/restartdaq
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/bin/bash

# Check if the current's user hutch uses daqmgr. If so,
# use the python utilities to manage the daq.
if [ "$(daqutils isdaqmgr)" = "true" ]; then
daqutils $(basename "$0") $@
exit 0
fi

usage()
{
cat << EOF
Expand All @@ -18,6 +11,7 @@ OPTIONS:
-p select partition (same as used last)
-s silent (do not email jana)
-c enable core files
-C (LCLS2 DAQMGR Hutches ONLY!) Select a cnf to use.
EOF
}

Expand All @@ -37,7 +31,7 @@ if [[ ($1 == "--help") || ($1 == "-h") ]]; then
fi

CORESIZE=0
while getopts "m:pwscd" OPTION
while getopts "m:pwscdC:" OPTION
do
case $OPTION in
p)
Expand All @@ -55,6 +49,9 @@ do
c)
CORESIZE=2000000000
;;
C)
DAQMGR_CNF=$OPTARG
;;
d)
DSSTEST=1
;;
Expand All @@ -66,14 +63,37 @@ do
esac
done

# Check if the current's user hutch uses daqmgr. If so,
# use the python utilities to manage the daq.
if [ "$(daqutils isdaqmgr)" = "true" ]; then
if [[ -n "$DAQMGR_CNF" ]]; then
for arg in "$@"; do
shift
case $arg in
-C)
shift
shift
;;
*)
set -- "$@"
;;
esac
done
daqutils --cnf "$DAQMGR_CNF" "$(basename "$0")" "$@"
else
daqutils "$(basename "$0")" "$@"
fi
exit 0
fi

if [[ $(whoami) != *'opr'* ]]; then
echo "Please run the DAQ from the operator account!"
exit
fi

HUTCH=$(get_info --gethutch)
CNFEXT=.cnf
CNFFILE=$HUTCH$CNFEXT
CNFFILE="$HUTCH""$CNFEXT"
if [ "$HOSTNAME" == 'cxi-daq' ]; then
PEXT=_0
CNFFILE=$HUTCH$PEXT$CNFEXT
Expand All @@ -96,6 +116,7 @@ cd /reg/g/pcds/dist/pds/"$HUTCH"/scripts/ || exit
DAQNETWORK='fez'
LCLS2_HUTCHES="rix, tmo, ued, txi"
if echo "$LCLS2_HUTCHES" | grep -iw "$HUTCH" > /dev/null; then
# shellcheck disable=SC1090
source /reg/g/pcds/dist/pds/"$HUTCH"/scripts/setup_env.sh
PROCMGR='procmgr'
DAQNETWORK='drp'
Expand All @@ -109,8 +130,7 @@ if [ "$IS_DAQ_HOST" == 0 ]; then
WORKINGHOSTS=''
#make sure at least cds is up.
for HOST in $HOSTS; do
ping -w 2 "$HOST" >/dev/null 2>&1
if [[ $? == 0 ]]; then
if [[ $(ping -w 2 "$HOST" >/dev/null 2>&1) == 0 ]]; then
WORKINGHOSTS=$WORKINGHOSTS' '$HOST
fi
done
Expand All @@ -125,12 +145,12 @@ else
DAQHOST=$(wheredaq)
fi

PLATFORM=$(grep 'if not platform' /reg/g/pcds/dist/pds/"$HUTCH"/scripts/$CNFFILE | awk '{print $NF}' | sed s/\'//g)
PLATFORM=$(grep 'if not platform' /reg/g/pcds/dist/pds/"$HUTCH"/scripts/"$CNFFILE" | awk '{print $NF}' | sed s/\'//g)
if [[ "$DAQHOST" != *$NOTRUNNING* ]]; then
echo stop the DAQ on "$DAQHOST" from "$HOSTNAME"
T="$(date +%s%N)"
$PROCMGR stop \
/reg/g/pcds/dist/pds/"$HUTCH"/scripts/$CNFFILE
/reg/g/pcds/dist/pds/"$HUTCH"/scripts/"$CNFFILE"


if [ -f /reg/g/pcds/dist/pds/"$HUTCH"/scripts/p"$PLATFORM"$CNFEXT.running ]; then
Expand All @@ -146,7 +166,7 @@ else
echo while DAQ reports to not run, will stop the DAQ on "$DAQHOST" from "$HOSTNAME" to clear the p"$PLATFORM"$CNFEXT.running file
T="$(date +%s%N)"
$PROCMGR stop \
/reg/g/pcds/dist/pds/"$HUTCH"/scripts/$CNFFILE
/reg/g/pcds/dist/pds/"$HUTCH"/scripts/"$CNFFILE"

if [ -f /reg/g/pcds/dist/pds/"$HUTCH"/scripts/p"$PLATFORM"$CNFEXT.running ]; then
echo 'the DAQ did not stop properly, exit now and try again follow the escalation procedure'
Expand All @@ -164,7 +184,7 @@ T="$(date +%s%N)"
echo start DAQ on "$AIMHOST"
if [ "$HOSTNAME" == "$AIMHOST" ]; then
$PROCMGR start \
/reg/g/pcds/dist/pds/"$HUTCH"/scripts/$CNFFILE -c $CORESIZE -o /reg/g/pcds/pds/"$HUTCH"/logfiles
/reg/g/pcds/dist/pds/"$HUTCH"/scripts/"$CNFFILE" -c $CORESIZE -o /reg/g/pcds/pds/"$HUTCH"/logfiles
else
ssh -Y "$AIMHOST" restartdaq
fi
Expand Down Expand Up @@ -199,7 +219,7 @@ if [ ${#DOWIN} != 0 ] || [ ${#SELPART} != 0 ]; then
SELPART=0
fi
fi
if [ -f /reg/neh/operator/"$HUTCH"\opr/bin/"$HUTCH"\_cleanup_windows_daq ]; then
if [ -f /reg/neh/operator/"$HUTCH"opr/bin/"$HUTCH"_cleanup_windows_daq ]; then
if [ ${#DOWIN} != 0 ]; then
echo 'This instrument does not have standard locations for DAQ windows setup'
fi
Expand All @@ -210,13 +230,13 @@ fi
if [ ${#DOWIN} != 0 ]; then
T="$(date +%s%N)"
if [ "$HUTCH" == 'xpp' ]; then
test=$(xdotool search --sync --onlyvisible --name 'ProcStat')
xdotool search --sync --onlyvisible --name 'ProcStat'
fi
if [ "$HUTCH" == 'xcs' ]; then
sleep 2
fi
echo 'resorting the windows now using: /reg/neh/operator/'"$HUTCH"'opr/bin/'"$HUTCH"'_cleanup_windows_daq'
/reg/neh/operator/"$HUTCH"\opr/bin/"$HUTCH"\_cleanup_windows_daq
/reg/neh/operator/"$HUTCH"opr/bin/"$HUTCH"_cleanup_windows_daq
Tdinter="$(($(date +%s%N)-T))"
Sinter="$((Tdinter/1000000000))"
Minter="$((Tdinter/1000000))"
Expand Down

0 comments on commit 028dab6

Please sign in to comment.