Exemple #1
0
int
main(int argc, char **argv)
{
    rstatus_i status = CC_OK;;
    FILE *fp = NULL;

    if (argc > 2) {
        show_usage();
        exit(EX_USAGE);
    }

    if (argc == 1) {
        log_stderr("launching server with default values.");
    } else {
        /* argc == 2 */
        if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
            show_usage();
            exit(EX_OK);
        }
        if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) {
            show_version();
            exit(EX_OK);
        }
        if (strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "--config") == 0) {
            option_describe_all((struct option *)&setting, nopt);
            exit(EX_OK);
        }
        if (strcmp(argv[1], "-s") == 0 || strcmp(argv[1], "--stats") == 0) {
            metric_describe_all((struct metric *)&stats, nmetric);
            exit(EX_OK);
        }
        fp = fopen(argv[1], "r");
        if (fp == NULL) {
            log_stderr("cannot open config: incorrect path or doesn't exist");
            exit(EX_DATAERR);
        }
    }

    if (option_load_default((struct option *)&setting, nopt) != CC_OK) {
        log_stderr("failed to load default option values");
        exit(EX_CONFIG);
    }

    if (fp != NULL) {
        log_stderr("load config from %s", argv[1]);
        status = option_load_file(fp, (struct option *)&setting, nopt);
        fclose(fp);
    }
    if (status != CC_OK) {
        log_stderr("failed to load config");
        exit(EX_DATAERR);
    }

    setup();
    option_print_all((struct option *)&setting, nopt);

    core_run(&worker_processor);

    exit(EX_OK);
}
Exemple #2
0
/*
 * utilities
 */
static void
test_setup(uint32_t policy, bool cas)
{
    option_load_default((struct option *)&options, OPTION_CARDINALITY(options));
    options.cuckoo_policy.val.vuint = policy;
    options.cuckoo_item_cas.val.vbool = cas;

    cuckoo_setup(&options, &metrics);
}
Exemple #3
0
/*
 * utilities
 */
static void
test_setup(uint32_t policy, bool cas, delta_time_i ttl)
{
    option_load_default((struct option *)&options, OPTION_CARDINALITY(options));
    options.cuckoo_policy.val.vuint = policy;
    options.cuckoo_item_cas.val.vbool = cas;
    options.cuckoo_max_ttl.val.vuint = ttl;
    options.cuckoo_datapool.val.vstr = DATAPOOL_PATH;

    cuckoo_setup(&options, &metrics);
}