Failsafe X Window server with automatic switch-over

The Failsafe option (Failsafe operation) combined with the scripting capability of the configuration tool (XmetaXtool: control and integration) allows to configure a failsafe X Window server. However, the XmetaX proxy must be executed on a failsafe host. Here, two single-headed X terminals — one and two — act as X Window servers. The common configuration file is specialized through the variable $terminal (Variables):

# /etc/opt/XSOXmetaX/terminal.conf

options +DynamicServer +Failsafe
screen $terminal
display $terminal:0.0
clipX 0
failsafeTimeout 10

The fact that one of the X terminals can fail, has two consequences:

When starting the XmetaX proxy it is not clear which of the X terminals is actually up.

If an X terminal fails during runtime, it is deleted from the configuration automatically due to the Failsafe option, and the other terminal has to be included into the configuration.

The following shell script covers both problems:

#!/bin/sh
# /etc/opt/XSOXmetaX/failsafe

DISPLAY=:0.0 export DISPLAY
export terminal
for terminal in one two
do
/opt/XSOXmetaX/bin/xmetax /etc/opt/XSOXmetaX/terminal.conf &
sleep 60
if /opt/XSOXmetaX/bin/xmetaxtool -print > /dev/null
then
break
fi
if [ "$terminal" = "two" ]
then
echo "$0: No server available" 1>&2
exit 1
fi
done


/opt/XSOXmetaX/bin/xmetaxtool -events \
| while read type terminal detail
do
case $detail
in destroyed)
case $terminal
in one)
terminal=two
;; two)
terminal=one
;; esac
echo "$0: Switching to server $terminal" 1>&2
if /opt/XSOXmetaX/bin/xmetaxtool -nogui \
/etc/opt/XSOXmetaX/terminal.conf
then
:
else
exit $?
fi
;; esac
done

In the second part, the shell script continuously reads and processes configuration changes (Reporting configuration changes): if a screen is deleted from the configuration, the respective other one is configured.

Copyright © 2018 X-Software GmbH
info@x-software.com