コード例 #1
0
int main(int argc, char **argv)
{
    LOG("THREAD %p", (gpointer)pthread_self());

    signal(SIGHUP, reload);
    signal(SIGINT, controlc);
    signal(SIGUSR1, exit);
    signal(SIGCHLD, SIG_IGN);

    mainLoop = g_main_loop_new(NULL, FALSE);

    parse_args(argc, argv);
    moloch_hex_init();
    moloch_config_init();
    moloch_writers_init();
    moloch_readers_init();
    moloch_plugins_init();
    moloch_plugins_load(config.rootPlugins);
    if (config.pcapReadOffline)
        moloch_readers_set("libpcap-file");
    else
        moloch_readers_set(NULL);
    if (!config.pcapReadOffline) {
        moloch_drop_privileges();
        config.copyPcap = 1;
        moloch_mlockall_init();
    }
    moloch_field_init();
    moloch_http_init();
    moloch_db_init();
    moloch_packet_init();
    moloch_config_load_local_ips();
    moloch_config_load_packet_ips();
    moloch_yara_init();
    moloch_parsers_init();
    moloch_session_init();
    moloch_plugins_load(config.plugins);
    g_timeout_add(1, moloch_ready_gfunc, 0);

    g_main_loop_run(mainLoop);

    LOG("Final cleanup");
    moloch_plugins_exit();
    moloch_parsers_exit();
    moloch_yara_exit();
    moloch_db_exit();
    moloch_http_exit();
    moloch_field_exit();
    moloch_config_exit();

    g_main_loop_unref(mainLoop);

    if (!config.dryRun && config.copyPcap) {
        moloch_writer_exit();
    }


    free_args();
    exit(0);
}
コード例 #2
0
ファイル: main.c プロジェクト: marchon/moloch
void cleanup(int UNUSED(sig))
{

    moloch_nids_exit();
    moloch_plugins_exit();
    moloch_detect_exit();
    moloch_yara_exit();
    moloch_db_exit();
    moloch_http_exit();
    moloch_config_exit();


    if (config.pcapReadFile)
        g_free(config.pcapReadFile);
    if (config.pcapReadDir)
        g_free(config.pcapReadDir);
    if (extraTags)
        g_strfreev(extraTags);
    exit(0);
}