diff --git a/scripts/JF02-buffer-worker.sh b/scripts/JF02-buffer-worker.sh index e8f0d2b..9c163c3 100644 --- a/scripts/JF02-buffer-worker.sh +++ b/scripts/JF02-buffer-worker.sh @@ -8,14 +8,18 @@ fi M=$1 -# Add ourselves to the user cpuset. -echo $$ > /sys/fs/cgroup/cpuset/user/tasks +H=`echo ${HOSTNAME} | sed 's/.psi.ch//'` -#coreAssociatedBuffer=(25 25 26 26 27 27 28 28 29) -coreAssociatedBuffer=(1 2 2 3 3 4 4 5 5) +case ${H} in +'sf-daq-4') + coreAssociatedBuffer=(11 12 13 14 15 16 17 18 19) + ;; +*) + CORES=(25 25 26 26 27 27 28 28 29) +esac initialUDPport=50020 port=$((${initialUDPport}+10#${M})) DETECTOR=JF02T09V02 -taskset -c ${coreAssociatedBuffer[10#${M}]} /usr/bin/sf_buffer ${DETECTOR} M${M} ${port} /gpfs/photonics/swissfel/buffer/${DETECTOR} ${M} +taskset -c ${coreAssociatedBuffer[10#${M}]} /usr/local/bin/sf_buffer ${DETECTOR} M${M} ${port} /gpfs/photonics/swissfel/buffer/${DETECTOR} ${M} diff --git a/scripts/JF02-buffer-worker@.service b/scripts/JF02-buffer-worker@.service index b175012..895e47e 100644 --- a/scripts/JF02-buffer-worker@.service +++ b/scripts/JF02-buffer-worker@.service @@ -8,7 +8,7 @@ BindsTo=JF02-buffer.service PermissionsStartOnly=true Type=idle User=root -ExecStart=/usr/bin/sh /home/writer/git/sf_daq_buffer/scripts/JF02-buffer-worker.sh %i +ExecStart=/usr/bin/sh /home/dbe/service_scripts/JF02-buffer-worker.sh %i TimeoutStartSec=10 RestartSec=10 diff --git a/scripts/JF02-buffer.service b/scripts/JF02-buffer.service index a3b442c..4302f4a 100644 --- a/scripts/JF02-buffer.service +++ b/scripts/JF02-buffer.service @@ -3,7 +3,7 @@ Description=All UDP-buffer instances of JF02 [Service] Type=oneshot -ExecStart=/usr/bin/sh /home/writer/git/sf_daq_buffer/scripts/JF02-buffer-worker.sh +ExecStart=/usr/bin/sh /home/dbe/service_scripts/JF02-buffer-worker.sh RemainAfterExit=yes [Install] diff --git a/scripts/JF02-stream.service b/scripts/JF02-stream.service index 27aaaa0..b070345 100644 --- a/scripts/JF02-stream.service +++ b/scripts/JF02-stream.service @@ -5,10 +5,10 @@ Description=stream service (to streamvis and live analysis) of JF02 PermissionsStartOnly=true Type=idle User=root -ExecStart=/usr/bin/sh /home/writer/git/sf_daq_buffer/scripts/JF02-stream.sh +ExecStart=/usr/bin/sh /home/dbe/service_scripts/JF02-stream.sh TimeoutStartSec=10 Restart=on-failure -RestartSec=10 +RestartSec=2 [Install] WantedBy=multi-user.target diff --git a/scripts/JF02-stream.sh b/scripts/JF02-stream.sh index 38b113d..832eb3c 100644 --- a/scripts/JF02-stream.sh +++ b/scripts/JF02-stream.sh @@ -1,5 +1,12 @@ #!/bin/bash -echo $$ > /sys/fs/cgroup/cpuset/user/tasks -coreAssociated="33,34,35" -taskset -c ${coreAssociated} /usr/bin/sf_stream /gpfs/photonics/swissfel/buffer/config/stream-JF02.json +H=`echo ${HOSTNAME} | sed 's/.psi.ch//'` +case ${H} in +'sf-daq-4') + coreAssociated="33,34,35" + ;; +*) + coreAssociated="12" +esac + +taskset -c ${coreAssociated} /usr/local/bin/sf_stream /gpfs/photonics/swissfel/buffer/config/stream-JF02.json diff --git a/scripts/JF02-vis.service b/scripts/JF02-vis.service new file mode 100644 index 0000000..a80fe66 --- /dev/null +++ b/scripts/JF02-vis.service @@ -0,0 +1,13 @@ +[Unit] +Description=streamvis: JF02 + +[Service] +User=root +TimeoutStartSec=2 +ExecStart=/bin/bash ./home/dbe/service_scripts/JF02-vis.sh +Restart=on-failure +RestartSec=4 + +[Install] +WantedBy=multi-user.target + diff --git a/scripts/JF02-vis.sh b/scripts/JF02-vis.sh new file mode 100644 index 0000000..7325b55 --- /dev/null +++ b/scripts/JF02-vis.sh @@ -0,0 +1,28 @@ +export PATH=/home/dbe/miniconda3/bin:$PATH + +source /home/dbe/miniconda3/etc/profile.d/conda.sh + +conda deactivate +conda activate vis + +PORT=5002 +PORT_BACKEND=9002 + +H=`echo ${HOSTNAME} | sed 's/.psi.ch//'` +BACKEND=${H} + + +case ${H} in +'sf-daq-4') + CORES='36,37' + ;; +*) + CORES='2' +esac + +taskset -c ${CORES} \ +streamvis alvra --allow-websocket-origin=${H}:${PORT} \ +--allow-websocket-origin=sf-daq-alvra:${PORT} --port=${PORT} \ +--address tcp://${BACKEND}:${PORT_BACKEND} \ +--page-title 4p5M_Alvra + diff --git a/scripts/sf_daq_buffer.setup.sh b/scripts/sf_daq_buffer.setup.sh new file mode 100755 index 0000000..828de0b --- /dev/null +++ b/scripts/sf_daq_buffer.setup.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# needed, otherwise executing with Ansible won't work +# see: https://github.com/conda/conda/issues/7267 +unset SUDO_UID SUDO_GID SUDO_USER + +if [ ! -d /home/dbe/git ]; then + echo "No git repo found, cloning it..." + mkdir /home/dbe/git +fi + +REPO=sf_daq_buffer +if [ ! -d /home/dbe/git/${REPO} ]; then + cd /home/dbe/git && git clone https://github.com/paulscherrerinstitute/${REPO}.git + + source /opt/rh/devtoolset-9/enable + cd /home/dbe/git/${REPO} && mkdir -p build && cd build/ && cmake3 .. && make +fi + + diff --git a/scripts/streamvis_setup.sh b/scripts/streamvis_setup.sh new file mode 100755 index 0000000..346ad3d --- /dev/null +++ b/scripts/streamvis_setup.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# needed, otherwise executing with Ansible won't work +# see: https://github.com/conda/conda/issues/7267 +unset SUDO_UID SUDO_GID SUDO_USER + +if [ ! -f /home/dbe/miniconda3/bin/conda ] +then + echo "Getting Miniconda" + wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + sh Miniconda3-latest-Linux-x86_64.sh -b -p /home/dbe/miniconda3 + + rm -rf Miniconda3-latest-Linux-x86_64.sh +fi + +# Setup the conda environment. +export PATH=/home/dbe/miniconda3/bin:$PATH + +source /home/dbe/miniconda3/etc/profile.d/conda.sh + +CONDA_ENV_NAME=vis +envtest=$(conda env list | grep ${CONDA_ENV_NAME}) + +if [ $? != 0 ]; then + echo "Creating the ${CONDA_ENV_NAME} environment" + conda create -n vis -y -c paulscherrerinstitute -c conda-forge streamvis +fi +