Skip to content

Commit 4fb2aea

Browse files
committed
Add description of backup server usage
1 parent 25fa69b commit 4fb2aea

File tree

4 files changed

+54
-7
lines changed

4 files changed

+54
-7
lines changed

docs/client_api/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def render_index_rst():
147147
:maxdepth: 1
148148
149149
desc/cli_scripting_in_batch
150+
desc/using_backup_servers
150151
"""
151152

152153
txt += """
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _using_backup_servers:
2+
3+
Using backup servers
4+
////////////////////
5+
6+
7+
The :code:`ecflow_client`, when running :term:`Task commands <child command>`, can be configured to contact
8+
alternate backup servers in case the primary server is not available -- this typically most useful in Operational environments.
9+
10+
.. important::
11+
12+
The use of backup servers is only supported for :term:`Task commands <child command>`, and not for User commands such as :code:`ecflow_client --ping` or :code:`ecflow_client --alter`.
13+
14+
A list of backup servers can be defined in a file, by convention located at :code:`$HOME/.ecf_hostfile`, with the following format:
15+
16+
.. code-block:: shell
17+
18+
# This is a comment
19+
host1 # port 3141 is used by default, when not specified
20+
host2:port2
21+
host3:port3
22+
23+
24+
To enable the :code:`ecflow_client` to read this file, and use the servers listed in it as backup servers, the following environment variable must be set before running the :code:`ecflow_client` command:
25+
26+
.. code-block:: shell
27+
28+
export ECF_HOSTFILE=$HOME/.ecf_hostfile
29+
30+
.. warning::
31+
32+
When performing a Task command, the :code:`ecflow_client` it will always first try to connect to the primary server, as defined by command line options or :code:`ECF_HOST`::code:`ECF_PORT`.
33+
If the first attemp to contact the primary server fails, the client will automatically retry contacting the primary server after waiting for a retry period of 10 seconds.
34+
Only after this second attempt has failed, will the :code:`ecflow_client` then immediatelly try to connect to the backup servers listed in the :code:`ECF_HOSTFILE`.
35+
36+
This implies that the :code:`ecflow_client` will not try to connect to the backup servers immediately, and thus contacting the backup server incurs in a minimum 10 seconds delay.

docs/client_api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The list of commands, amongst other details, can be displayed by using the optio
3333
:maxdepth: 1
3434

3535
desc/cli_scripting_in_batch
36+
desc/using_backup_servers
3637

3738

3839
.. rubric:: Reference Commands

libs/client/src/ecflow/client/ClientInvoker.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -594,25 +594,34 @@ int ClientInvoker::do_invoke_cmd(Cmd_ptr cts_cmd) const {
594594

595595
// Wait a bit before trying to connect again, but only if no_of_tries > 0
596596
no_of_tries--;
597-
if (no_of_tries > 0)
597+
if (no_of_tries > 0) {
598598
sleep(retry_connection_period);
599+
}
599600
}
600601

601-
// Don't bother with other hosts when:
602+
//
603+
// The ecFlow client may try to connect to multiple hosts, as specified in the ECF_HOSTFILE
604+
//
605+
// Attempting other hosts only happens for Task commands.
606+
//
607+
// The multiple hosts connection is ***NOT*** attempted when:
602608
// 1/ Testing
603-
// 2/ ping-ing
604-
// 3/ ECF_DENIED has been set
605-
// 4/ Dealing with non tasks based request
609+
// 2/ Executing Ping command
610+
// 3/ Environment variable ECF_DENIED is set
611+
// 4/ Executing any User command
612+
//
606613
if (!cts_cmd->connect_to_different_servers() || test_ || cts_cmd->ping_cmd() || clientEnv_.denied()) {
607614
std::stringstream ss;
608615
ss << TimeStamp::now() << "Request( " << cts_cmd->print_short() << " )";
609-
if (clientEnv_.denied())
616+
if (clientEnv_.denied()) {
610617
ss << " ECF_DENIED ";
618+
}
611619
ss << ", Failed to connect to " << client_env_host_port() << ". After " << connection_attempts_
612620
<< " attempts. Is the server running ?\n";
613621
// Only print client environment if not pinging
614-
if (!cts_cmd->ping_cmd())
622+
if (!cts_cmd->ping_cmd()) {
615623
ss << clientEnv_.toString() << endl;
624+
}
616625
server_reply_.set_error_msg(ss.str());
617626
return 1;
618627
}

0 commit comments

Comments
 (0)