diff --git a/recipes-app/fofb-opcua-server/files/fofb-opcua-server.sh b/recipes-app/fofb-opcua-server/files/fofb-opcua-server.sh index 478e2b89be1bcdcc9a55c0c01d8ffd43102e2d3d..ec2a51109f64da24e12c9164e08ec616e5e2174d 100755 --- a/recipes-app/fofb-opcua-server/files/fofb-opcua-server.sh +++ b/recipes-app/fofb-opcua-server/files/fofb-opcua-server.sh @@ -23,16 +23,33 @@ start() { echo "starting" > $LOCK_FILE stdbuf -oL opcua-generic-chimeratk-server01 &>> $LOG_FILE & - # Wait for server started - (tail -F -n0 $LOG_FILE & ) | grep -q "All application modules are running" + (tail -F -n0 $LOG_FILE & ) | grep -q "ChimeraTK::logic_error" && (echo "crashed" > $LOCK_FILE) & + (tail -F -n0 $LOG_FILE & ) | grep -q "All application modules are running" && (echo "started" > $LOCK_FILE) & - # Restart FPGA application because server writes all zeros - echo "Restart FPGA application" >> $LOG_FILE - /etc/init.d/fofb-init.sh start + # Wait for server started or crashed + while : + do + state=$(cat $LOCK_FILE) + if [ "$state" = "started" ] ; then + + # Reset the FPGA + echo "Init again application" >> $LOG_FILE + /etc/init.d/fofb-init.sh start >> $LOG_FILE + + success + break + fi + + if [ "$state" = "crashed" ] ; then + failure + break + fi + + sleep 1 + done + + kill $(jobs -p) - ### Create the lock file ### - echo "started" > $LOCK_FILE - success $"fofb-opcua server startup" }