" -k, --key <file> location of server private key\n"
" -C, --CAdir <dir> directory containing CA certificates\n"
" -b, --book send events to bookkeeping server only\n"
- " -i, --pidfile pid file\n"
+ " -i, --pidfile pid file\n"
" -l, --log-server <host> specify address of log server\n"
" -s, --socket <path> non-default path of local socket\n"
" -L, --lazy [<timeout>] be lazy when closing connections to servers (default, timeout==0 means turn lazy off)\n"
" -p, --parallel [<num>] use <num> parallel streams to the same server\n"
" -q, --queue-low <num> queue length that enables another insertions\n"
" -Q, --queue-high <num> max queue length\n"
+ " -F, --conf <file> load configuration from config file\n"
#ifdef LB_PERF
" -n, --nosend PERFTEST: consume events instead of sending\n"
" -S, --nosync PERFTEST: do not check logd files for lost events\n"
char *CAcert_dir = NULL;
char *log_server = NULL;
char *socket_path = DEFAULT_SOCKET;
+static char *conf_file = NULL;
+static char *config = NULL;
static struct option const long_options[] =
{
{"parallel", optional_argument, 0, 'p'},
{"queue_size_low", required_argument, 0, 'q'},
{"queue_size_high", required_argument, 0, 'Q'},
+ {"conf", required_argument, 0, 'F'},
#ifdef LB_PERF
{"nosend", no_argument, 0, 'n'},
{"nosync", no_argument, 0, 'S'},
"p" /* parallel */
"q:"
"Q:"
+ "F:" /* conf file */
#ifdef LB_PERF
"n" /* nosend */
"S" /* nosync */
queue_size_high = atoi(optarg);
break;
+ case 'F':
+ conf_file = strdup(optarg);
+ break;
+
#ifdef LB_PERF
case 'n':
nosend = 1;
}
+char *load_conf_file(char *filename)
+{
+ struct stat fs;
+ FILE *cf;
+ char *s;
+
+ if(stat(filename, &fs) < 0) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "Could not stat config file %s: %s\n", filename, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ s = malloc(fs.st_size);
+ if(s == NULL) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "Not enough memory for config file");
+ exit(EXIT_FAILURE);
+ }
+ cf = fopen(filename, "r");
+ if(cf == NULL) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "Error opening config file %s: %s\n", filename, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ if(fread(s, fs.st_size, 1, cf) != fs.st_size) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "Error reading config file %s: %s\n", filename, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ fclose(cf);
+ return s;
+}
+
+
void handle_signal(int num) {
glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Received signal %d\n", num);
exit(EXIT_FAILURE);
}
+ /* parse config file, if any */
+ if(conf_file != NULL) {
+ config = load_conf_file(conf_file);
+ }
+
/* check for reasonable queue lengths */
if(queue_size_low == 0 && queue_size_high > 0 ||
queue_size_low > queue_size_high) {
return -1; \
}
-int plugin_init(const char *plugin_name)
+int plugin_init(const char *plugin_name, const char *cfg)
{
char err[256];
void *dl_handle;
}
plugin->next = plugins;
- DL_RESOLVESYM(plugin->plugin_def.plugin_init, dl_handle, "plugin_init", int(*)());
+ DL_RESOLVESYM(plugin->plugin_def.plugin_init, dl_handle, "plugin_init", int(*)(char *));
DL_RESOLVESYM(plugin->plugin_def.plugin_supports_scheme, dl_handle, "plugin_supports_scheme", int(*)(const char *));
DL_RESOLVESYM(plugin->plugin_def.event_queue_connect, dl_handle, "event_queue_connect", int (*)(struct event_queue*));
DL_RESOLVESYM(plugin->plugin_def.event_queue_send, dl_handle, "event_queue_send", int (*)(struct event_queue *));
DL_RESOLVESYM(plugin->plugin_def.event_queue_close, dl_handle, "event_queue_close", int (*)(struct event_queue *));
- return (*plugin->plugin_def.plugin_init)();
+ return (*plugin->plugin_def.plugin_init)(cfg);
}