diff --git a/src/main.c b/src/main.c index 242ccea..b5f1a75 100644 --- a/src/main.c +++ b/src/main.c @@ -52,6 +52,9 @@ extern char ** environ; */ #define CONFIG_DEBUG_MODE_KEY "ZLDEBUG" +/* delay between starting each component, in seconds */ +#define CONFIG_SLEEP_TIME_KEY "ZLDELAYS" +#define DEFAULT_SLEEP_TIME_SEC 5 #define ZOWE_CONFIG_NAME "ZOWEYAML" #define CONFIG_DEBUG_MODE_VALUE "ON" @@ -117,6 +120,7 @@ typedef struct zl_int_array_t { typedef struct zl_config_t { bool debug_mode; + int sleep_time; } zl_config_t; typedef struct zl_comp_t { @@ -180,7 +184,11 @@ struct { pid_t pid; char userid[9]; - + + /* Sleep time of 5 seconds during startup of components + is to temporarily workaround parallelism performance issues on z/OS + If the situation improves in the future, we can reduce this. + */ } zl_context = {.config = {.debug_mode = false}, .userid = "(NONE)"} ; // Wrapper for wtoPrintf3 @@ -1002,13 +1010,17 @@ static int start_component(zl_comp_t *comp) { return 0; } -static int start_components(void) { +static int start_components(zl_config_t *config) { INFO(MSG_STARTING_COMPS); int rc = 0; for (size_t i = 0; i < zl_context.child_count; i++) { + if (config->sleep_time) { + INFO(MSG_COMP_SLEEP, config->sleep_time); + sleep(config->sleep_time); + } if (start_component(&zl_context.children[i])) { ERROR(MSG_COMP_START_FAILED, zl_context.children[i].name); rc = -1; @@ -1316,6 +1328,17 @@ static zl_config_t read_config(int argc, char **argv) { result.debug_mode = true; } + char *sleep_value = getenv(CONFIG_SLEEP_TIME_KEY); + if (sleep_value) { + char *end; + long int sleep_number = strtol(sleep_value, &end, 10); + result.sleep_time = sleep_number; + INFO("sleep_time changed to %d\n",sleep_number); + } else { + result.sleep_time = DEFAULT_SLEEP_TIME_SEC; + INFO("Using sleep_time default of %d\n",result.sleep_time); + } + return result; } @@ -1897,6 +1920,12 @@ int main(int argc, char **argv) { printf_wto(MSG_CTX_INIT_FAILED); // Manual sys log print (messages not set here yet) exit(EXIT_FAILURE); } + + if (config.sleep_time) { + INFO(MSG_CONFIG_SLEEP, config.sleep_time); + } else { + INFO("Launcher is not using sleeps\n"); + } cfgSetConfigPath(configmgr, ZOWE_CONFIG_NAME, zl_context.configmgr_path); int parm_member_len = strlen(zl_context.parm_member); @@ -1957,7 +1986,7 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } - start_components(); + start_components(&config); if (start_console_tread()) { ERROR(MSG_CONS_START_ERR); diff --git a/src/msg.h b/src/msg.h index a862cc6..5ec19bd 100644 --- a/src/msg.h +++ b/src/msg.h @@ -88,6 +88,8 @@ #define MSG_CFG_LOAD_FAIL MSG_PREFIX "0072E" " Launcher Could not load configurations\n" #define MSG_CFG_SCHEMA_FAIL MSG_PREFIX "0073E" " Launcher Could not load schemas, status=%d\n" #define MSG_NO_LOG_CONTEXT MSG_PREFIX "0074E" " Log context was not created\n" +#define MSG_CONFIG_SLEEP MSG_PREFIX "0075I" " Launcher configured to stagger initial component start by %d seconds\n" +#define MSG_COMP_SLEEP MSG_PREFIX "0076I" " Waiting %d seconds before component start\n" #define MSG_LINE_LENGTH "-- If you cant see '500' at the end of the line, your log is too short to read!80--------90------ 100----------------------125----------------------150----------------------175----------------------200----------------------225----------------------250----------------------275----------------------300----------------------325----------------------350----------------------375----------------------400----------------------425----------------------450----------------------475----------------------500\n" #endif // MSG_H