#! /bin/csh -f # # full restart of DCSS control system # # if(! $?reason) set reason = "" set user = `whoami` set host = `hostname -s` set path = ( /programs/beamline $path ) # make sure we run as root if("$user" != "root") then # restart control system as root sudo $0 $* if($status) exit $status # now we are an ordinary user # fire up the GUI as the ordinary user if("$1" == "") then echo "you are $user" echo "starting blu-ice" go endif exit endif # first, kill everything killall: echo "killing touch screen on graphics1" ssh -x -a -k -n graphics1 "killall -9 touch.tcl" >& /dev/null ssh -x -a -k -n graphics1 "killall -9 watchdog.tcl" >& /dev/null ssh -x -a -k -n graphics3 "killall -9 watchdog.tcl" >& /dev/null echo "killing all control system jobs on $host..." foreach pid ( `ps -lea | awk '$NF ~ /-ice|^det_api|^pmac|^wago|^labview|^simdhs|^dhs|^dcss|^adxv|^touch|^watchdog/{print $4}'` ) if ($pid == $$) continue echo -n "killing: $host " ps -p $pid | tail +2 ( kill -9 $pid ) >& /dev/null end # allow for windowless restart if("$1" == "noreason") set reason = "NO REASON" # put EVERYTHING in pretend mode set pretend if("$*" =~ "pretend") set pretend = "pretend" # do this if we just want a total shutdown if("$1" == "die") then if($?SERVER_DIE) exit ssh -x -a -k -n server "setenv SERVER_DIE; $0 die" exit endif set maxnum = `ls -1 /data/log/ | awk -F "[\.]" '/dcss/{print $NF+1}' | sort -n | tail -1` if ("$1" == "server") then set maxnum = `ls -1 /data/log/ | awk -F "[\.]" '/dcss/{print $NF}' | sort -n | tail -1` # copy the module logs on the server foreach log ( `ls -1 /mnt/adsc/pv_sw/bin_442/ | grep log` ) cp -p /mnt/adsc/pv_sw/bin_442/$log /data/log/${log}.$maxnum end # only lauch server jobs on the "server" machine goto servers else # rotate the log files from the local host set maxnum = `ls -1 /data/log/ | awk -F "[\.]" '/dcss/{print $NF+1}' | sort -n | tail -1` echo "backing up logs as run # $maxnum" foreach log ( det_api_workstation.log labviewDHS.log pmac2DHS.log touch.log watchdog.log dcss.log detectorDHS.log pmac1DHS.log simDHS.log wagoDHS.log ) if(-e /data/log/$log) mv /data/log/$log /data/log/${log}.$maxnum end # rm -f $XFORMSTATUSFILE # echo -n "1 /data/${USER}/" >! $XFORMSTATUSFILE # ls -1rt /data/${USER}/ | grep img | tail -1 >> $XFORMSTATUSFILE # try to force NFS to sync sync # you never know what crazy stuff users will type in... set noglob while ( "$reason" == "" ) set reason = `Xdialog --title "why did you restart?" --under-mouse --editbox "no reason" 0 0 |& cat` end change.com "DCSS restart \#${maxnum} $reason" /bin/echo -E "DCSS restart #${maxnum} at `date` because: $reason" | mail -s "DCSS restart #${maxnum}" jmholton@lbl.gov /bin/echo -E "DCSS restart #${maxnum} at `date` because: $reason" | mail -s "DCSS restart #${maxnum}" kafrankel@lbl.gov /bin/echo -E "DCSS restart #${maxnum} at `date` because: $reason" | mail -s "DCSS restart #${maxnum}" gmeigs@lbl.gov /bin/echo -E "DCSS restart #${maxnum} at `date` because: $reason" | mail -s "DCSS restart #${maxnum}" jjplecs@lbl.gov unset noglob # only do log rotation on the local machine echo "waiting for NFS to sync..." sync sleep 5 # now jump over to server (no fancy ssh features and make it just like a login shell) echo "$0 server $pretend" | ssh -x -a -k server "/bin/csh -l" # now go back one level and launch GUI exit endif servers: echo "\n\nstarting servers..." # reset the detector control computers #foreach module ( detector0 detector1 detector2 detector3 detector4 detector5 detector6 detector7 detector8 ) foreach module ( detector1 detector2 detector3 detector4 ) # send the reset signal echo -n "$module restart " echo "restart" | sock_exchange.tcl $module 8038 1 echo "" end # start up the detector control proxy server echo "starting det_api_workstation on $host" source /programs/adsc/env/bl831_env /programs/adsc/bin/linux/det_api_workstation >&! /data/log/det_api_workstation.log & # start up DCSS echo "starting dcss on $host" cd /programs/DCSS_3.0/dcss/linux/ #./dcss -r bl831.dat /programs/DCSS_3.0/dcss/linux/dcss -s >&! /data/log/dcss.log & # start up all the DHSs echo "starting pmac1 dhs on $host" /programs/DCSS_3.0/dhs/linux/pmac1DHS.tcl $pretend >&! /data/log/pmac1DHS.log & echo "starting pmac2 dhs on $host" /programs/DCSS_3.0/dhs/linux/pmac2DHS.tcl $pretend >&! /data/log/pmac2DHS.log & echo "starting labview dhs on $host" /programs/DCSS_3.0/dhs/linux/labviewDHS.tcl $pretend >&! /data/log/labviewDHS.log & echo "starting wago dhs on $host" /programs/DCSS_3.0/dhs/linux/wagoDHS.tcl $pretend >&! /data/log/wagoDHS.log & echo "starting detector dhs on $host" cd /programs/DCSS_3.0/dhs/linux /programs/DCSS_3.0/dhs/linux/dhs detector >&! /data/log/detectorDHS.log & echo "starting simulator dhs on $host" cd /programs/DCSS_3.0/simdhs/scripts/ /programs/DCSS_3.0/simdhs/scripts/simdhs.tcl >&! /data/log/simDHS.log & # launch the watchdog program on the server (using a login shell to protect against thread hangs) echo "starting watchdog on $host" #echo "/programs/beamline/watchdog.tcl" | /bin/csh -l >&! /data/log/watchdog.log & /programs/beamline/watchdog.tcl >&! /data/log/watchdog.log & # launch the touch-screen control program echo "starting touchscreen on graphics1" echo "/programs/beamline/touch.tcl >&! /data/log/touch.log &" | ssh -x -a -k graphics1 "csh -l" >& /dev/null # quit now if we are just firing up servers if ("$1" == "server") exit # clean up the runinfo messages? cleanup_runs.com