How to reconnect to the Tango HOST at device server startup time#
The following C++ snippet shows how to allow the Device Server to start before the Tango Host is available. In this mode the device server will wait until it can reach the tango host. This mode of operation does not make sense to combine with the File Database as that is always immediately available.
Set _daemon
and _sleep_between_connect
from Tango::Util
before initialization in the main
function.
This function is located in main.cpp
when the device server was generated with Pogo:
1 int main(int argc, char *argv[])
2 {
3 // Set an automatic retry on database connection
4 //----------------------------------------------
5 Tango::Util::_daemon = true;
6 Tango::Util::_sleep_between_connect = 5;
7
8 // Initialize the device server
9 //--------------------------------
10 tg = Tango::Util::init(argc, argv);
11
12 ...
13 }
The device server will retry to connect to the tango host in case of failures periodically. The retry interval is here set to 5 seconds, it defaults to 60 seconds.