void TSPluginInit(int argc, const char *argv[]) { TSPluginRegistrationInfo info; TSCont main_cont, config_cont; config_holder_t *config_holder; info.plugin_name = PLUGIN_TAG; info.vendor_name = "Comcast"; info.support_email = "*****@*****.**"; astatsLoad = time(NULL); if (TSPluginRegister(TS_SDK_VERSION_2_0, &info) != TS_SUCCESS) TSError("Plugin registration failed. \n"); if (!check_ts_version()) { TSError("Plugin requires Traffic Server 2.0 or later\n"); return; } config_holder = new_config_holder(argc > 1 ? argv[1] : NULL); main_cont = TSContCreate(astats_origin, NULL); TSContDataSet(main_cont, (void *) config_holder); TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, main_cont); config_cont = TSContCreate(config_handler, TSMutexCreate()); TSContDataSet(config_cont, (void *) config_holder); TSMgmtUpdateRegister(config_cont, PLUGIN_TAG); /* Create a continuation with a mutex as there is a shared global structure containing the headers to add */ TSDebug(PLUGIN_TAG, "astats module registered, path: '%s'", config_holder->config->stats_path); }
/** * Initialize the IronBee ATS plugin. * * Performs initializations required by ATS. * * @param[in] argc Command-line argument count * @param[in] argv Command-line argument list */ static void *ibinit(void *x) { TSCont cont = x; ib_status_t rc; rc = ironbee_init(&module_data); if (rc != IB_OK) { TSError("[ironbee] initialization failed: %s", ib_status_to_string(rc)); goto Lerror; } /* connection initialization & cleanup */ TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, cont); /* now all's up and running, flag it to our READ_REQUEST_HDR hook */ TSContDataSet(cont, &module_data); /* Register our continuation for management update for traffic_line -x * Note that this requires Trafficserver 3.3.5 or later, or else * apply the patch from bug TS-2036 */ TSMgmtUpdateRegister(cont, "ironbee"); return NULL; Lerror: TSError("[ironbee] Unable to initialize plugin (disabled)."); return NULL; }
void TSPluginInit(int argc, const char *argv[]) { TSPluginRegistrationInfo info; TSCont main_cont, config_cont; plugin_state_t *pstate; invalidate_t *iptr = NULL; bool disable_timed_reload = false; TSDebug(LOG_PREFIX, "Starting plugin init"); pstate = (plugin_state_t *)TSmalloc(sizeof(plugin_state_t)); init_plugin_state_t(pstate); int c; static const struct option longopts[] = {{"config", required_argument, NULL, 'c'}, {"log", required_argument, NULL, 'l'}, {"disable-timed-reload", no_argument, NULL, 'd'}, {NULL, 0, NULL, 0}}; while ((c = getopt_long(argc, (char *const *)argv, "c:l:", longopts, NULL)) != -1) { switch (c) { case 'c': pstate->config_file = TSstrdup(optarg); break; case 'l': if (TS_SUCCESS == TSTextLogObjectCreate(optarg, TS_LOG_MODE_ADD_TIMESTAMP, &pstate->log)) { TSTextLogObjectRollingEnabledSet(pstate->log, 1); TSTextLogObjectRollingIntervalSecSet(pstate->log, LOG_ROLL_INTERVAL); TSTextLogObjectRollingOffsetHrSet(pstate->log, LOG_ROLL_OFFSET); } break; case 'd': disable_timed_reload = true; break; default: break; } } if (!pstate->config_file) { TSError("[regex_revalidate] Plugin requires a --config option along with a config file name"); free_plugin_state_t(pstate); return; } if (!load_config(pstate, &iptr)) { TSDebug(LOG_PREFIX, "Problem loading config from file %s", pstate->config_file); } else { pstate->invalidate_list = iptr; list_config(pstate, iptr); } info.plugin_name = LOG_PREFIX; info.vendor_name = "Apache Software Foundation"; info.support_email = "*****@*****.**"; if (TSPluginRegister(&info) != TS_SUCCESS) { TSError("[regex_revalidate] Plugin registration failed"); free_plugin_state_t(pstate); return; } else { TSDebug(LOG_PREFIX, "Plugin registration succeeded"); } if (!check_ts_version()) { TSError("[regex_revalidate] Plugin requires Traffic Server %d.%d.%d", TS_VERSION_MAJOR, TS_VERSION_MINOR, TS_VERSION_MICRO); free_plugin_state_t(pstate); return; } pcre_malloc = &ts_malloc; pcre_free = &ts_free; main_cont = TSContCreate(main_handler, NULL); TSContDataSet(main_cont, (void *)pstate); TSHttpHookAdd(TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, main_cont); config_cont = TSContCreate(config_handler, TSMutexCreate()); TSContDataSet(config_cont, (void *)pstate); TSMgmtUpdateRegister(config_cont, LOG_PREFIX); if (!disable_timed_reload) { TSContScheduleOnPool(config_cont, CONFIG_TMOUT, TS_THREAD_POOL_TASK); } TSDebug(LOG_PREFIX, "Plugin Init Complete"); }