Allow to pass RESPAWN_THESHOLD_DEFAULT, DRESPAWN_TIMEOUT_DEFAULT and RESPAWN_RETRY_DEFAULT as parameters to cmake to change the default respawn behavior.
This can be used to set the default respawn mode to infinite retries for example. Signed-off-by: Helmut Schaa <helmut.sc...@googlemail.com> --- CMakeLists.txt | 12 ++++++++++++ service/instance.c | 4 +++- service/instance.h | 12 +++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6af17a3..721a381 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,18 @@ SET(SOURCES procd.c signal.c watchdog.c state.c inittab.c rcS.c ubus.c system.c SET(LIBS ubox ubus json-c blobmsg_json json_script) +IF(RESPAWN_THESHOLD_DEFAULT) + ADD_DEFINITIONS(-DRESPAWN_THESHOLD_DEFAULT=${RESPAWN_THESHOLD_DEFAULT}) +ENDIF() + +IF(RESPAWN_TIMEOUT_DEFAULT) + ADD_DEFINITIONS(-DRESPAWN_TIMEOUT_DEFAULT=${RESPAWN_TIMEOUT_DEFAULT}) +ENDIF() + +IF(RESPAWN_RETRY_DEFAULT) + ADD_DEFINITIONS(-DRESPAWN_RETRY_DEFAULT=${RESPAWN_RETRY_DEFAULT}) +ENDIF() + IF(DEBUG) ADD_DEFINITIONS(-DDEBUG -g3) ENDIF() diff --git a/service/instance.c b/service/instance.c index 40ff021..9d4df7c 100644 --- a/service/instance.c +++ b/service/instance.c @@ -709,7 +709,9 @@ instance_config_parse(struct service_instance *in) if (tb[INSTANCE_ATTR_RESPAWN]) { int i = 0; - uint32_t vals[3] = { 3600, 5, 5}; + uint32_t vals[3] = { RESPAWN_THRESHOLD_DEFAULT, + RESPAWN_TIMEOUT_DEFAULT, + RESPAWN_RETRY_DEFAULT }; blobmsg_for_each_attr(cur2, tb[INSTANCE_ATTR_RESPAWN], rem) { if ((i >= 3) && (blobmsg_type(cur2) == BLOBMSG_TYPE_STRING)) diff --git a/service/instance.h b/service/instance.h index 3fb33e9..ab05f20 100644 --- a/service/instance.h +++ b/service/instance.h @@ -20,7 +20,17 @@ #include <libubox/ustream.h> #include "../utils/utils.h" -#define RESPAWN_ERROR (5 * 60) +#ifndef RESPAWN_THRESHOLD_DEFAULT +#define RESPAWN_THRESHOLD_DEFAULT 3600 +#endif + +#ifndef RESPAWN_TIMEOUT_DEFAULT +#define RESPAWN_TIMEOUT_DEFAULT 5 +#endif + +#ifndef RESPAWN_RETRY_DEFAULT +#define RESPAWN_RETRY_DEFAULT 5 +#endif struct jail { bool procfs; -- 1.8.4.5 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel