diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-03-09 19:48:29 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-03-09 19:48:29 +0100 |
commit | 9d5549d6ba06d34597f00da21d19c6375a70f8aa (patch) | |
tree | 7e280f48014f248ba621f204f8da8ded6c0c71d5 /src | |
parent | 74facbead4d93a10248c6edf890fd8211e230229 (diff) | |
download | exchange-9d5549d6ba06d34597f00da21d19c6375a70f8aa.tar.xz |
retry on failure
Diffstat (limited to 'src')
-rw-r--r-- | src/exchange/taler-exchange-httpd.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index c88ddd7c8..d247d981b 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -81,6 +81,11 @@ #define UNIX_BACKLOG 50 /** + * How often will we try to connect to the database before giving up? + */ +#define MAX_DB_RETRIES 5 + +/** * Above what request latency do we start to log? */ #define WARN_LATENCY GNUNET_TIME_relative_multiply ( \ @@ -1965,11 +1970,20 @@ exchange_serve_process_config (void) GNUNET_free (attr_enc_key_str); } - if (NULL == - (TEH_plugin = TALER_EXCHANGEDB_plugin_load (TEH_cfg))) + for (unsigned int i = 0; i<MAX_DB_RETRIES; i++) + { + TEH_plugin = TALER_EXCHANGEDB_plugin_load (TEH_cfg); + if (NULL != TEH_plugin) + break; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failed to connect to DB, will try again %u times\n", + MAX_DB_RETRIES - i); + sleep (1); + } + if (NULL == TEH_plugin) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to initialize DB subsystem\n"); + "Failed to initialize DB subsystem. Giving up.\n"); return GNUNET_SYSERR; } return GNUNET_OK; |