Skip to content
Snippets Groups Projects
Commit e49b2cda authored by BRONES Romain's avatar BRONES Romain
Browse files

feat(fofb-opcua): Add wait for server ready

* Use the lock file to store status
* While server is starting, the status will be "starting"
* After proper start, apply a FPGA reset and local config
parent daefa8ab
Branches
No related tags found
No related merge requests found
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
. /etc/init.d/functions . /etc/init.d/functions
LOG_FILE=/var/log/fofb-opcua-server.log LOG_FILE=/var/log/fofb-opcua-server.log
LOCK_FILE=/var/lock/subsys/fofb-opcua-server.log LOCK_FILE=/var/lock/subsys/fofb-opcua-server
# Start the service # Start the service
start() { start() {
if [ -f $LOCK_FILE ]; then if [ -f $LOCK_FILE ]; then
echo "fofb-opcua server already running" echo "fofb-opcua server already running, status: $(cat $LOCK_FILE)"
exit 1 exit 1
fi fi
...@@ -20,15 +20,19 @@ start() { ...@@ -20,15 +20,19 @@ start() {
ln -sf /opt/fofb/map/appuio.dmap devices.dmap ln -sf /opt/fofb/map/appuio.dmap devices.dmap
# Start server # Start server
echo "starting" > $LOCK_FILE
stdbuf -oL opcua-generic-chimeratk-server01 &>> $LOG_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"
# Reset the FPGA # Reset the FPGA
echo "Reset FPGA and reconfigure" >> $LOG_FILE echo "Reset FPGA and reconfigure" >> $LOG_FILE
/etc/init.d/fw_plreset.sh >> $LOG_FILE /etc/init.d/fw_plreset.sh >> $LOG_FILE
fofb-configurator --config /opt/fofb/cfg/config_register --dmap /opt/fofb/opcua-server/devices.dmap >> $LOG_FILE fofb-configurator --config /opt/fofb/cfg/config_register --dmap /opt/fofb/opcua-server/devices.dmap >> $LOG_FILE
### Create the lock file ### ### Create the lock file ###
touch $LOCK_FILE echo "started" > $LOCK_FILE
success $"fofb-opcua server startup" success $"fofb-opcua server startup"
} }
...@@ -41,6 +45,15 @@ stop() { ...@@ -41,6 +45,15 @@ stop() {
rm -f $LOCK_FILE rm -f $LOCK_FILE
} }
status() {
if [ -f $LOCK_FILE ]; then
echo "fofb-opcua server status: $(cat $LOCK_FILE)"
else
echo "fofb-opcua server status: stopped"
fi
}
### main logic ### ### main logic ###
case "$1" in case "$1" in
start) start)
...@@ -50,7 +63,7 @@ case "$1" in ...@@ -50,7 +63,7 @@ case "$1" in
stop stop
;; ;;
status) status)
status opcua-generic-chimeratk-server01 status
;; ;;
restart|reload|condrestart) restart|reload|condrestart)
stop stop
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment