From 028dab67f1b3c0dde00c079c6e46b38b478bb7b8 Mon Sep 17 00:00:00 2001 From: gadorlhiac Date: Fri, 25 Oct 2024 09:10:56 -0700 Subject: [PATCH] ENH Add flag to restartdaq --- scripts/restartdaq | 56 +++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/scripts/restartdaq b/scripts/restartdaq index 54961624..2e819ab1 100755 --- a/scripts/restartdaq +++ b/scripts/restartdaq @@ -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 @@ -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 } @@ -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) @@ -55,6 +49,9 @@ do c) CORESIZE=2000000000 ;; + C) + DAQMGR_CNF=$OPTARG + ;; d) DSSTEST=1 ;; @@ -66,6 +63,29 @@ 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 @@ -73,7 +93,7 @@ fi HUTCH=$(get_info --gethutch) CNFEXT=.cnf -CNFFILE=$HUTCH$CNFEXT +CNFFILE="$HUTCH""$CNFEXT" if [ "$HOSTNAME" == 'cxi-daq' ]; then PEXT=_0 CNFFILE=$HUTCH$PEXT$CNFEXT @@ -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' @@ -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 @@ -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 @@ -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' @@ -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 @@ -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 @@ -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))"