Beispiel #1
0
int main (void)
{
    interface_t *interface = interface_new ();
    while (true) {
        zmsg_t *msg = interface_recv (interface);
        if (!msg)
            break;              //  Interrupted
        zmsg_dump (msg);
    }
    interface_destroy (&interface);
    return 0;
}
Beispiel #2
0
void fit_destroy(fitinfo *fit)
{
  pars_destroy(&fit->pars);
  profile_destroy(&fit->p);
  model_destroy(&fit->m);
  data_destroy(&fit->dataA);
  data_destroy(&fit->dataB);
  data_destroy(&fit->dataC);
  data_destroy(&fit->dataD);
  interface_destroy(&fit->rm);
  if (fit->worksize>0) free(fit->work);
  if (fit->capacity>0) free(fit->fitQ);
  fit->capacity = -1;
  fit->nQ = 0;
  fit->worksize = 0;
}
Beispiel #3
0
void
state_menu_close(void *ptr)
{
	interface_destroy(ui);
}
Beispiel #4
0
/**
 * main function for FOSSology scheduler, does command line parsing,
 * Initialization and then simply enters the event loop.
 *
 * @param argc the command line argument cound
 * @param argv the command line argument values
 * @return if the program ran correctly
 */
int main(int argc, char** argv)
{
  /* locals */
  gboolean db_reset = FALSE;  // flag to reset the job queue upon database connection
  gboolean ki_kill  = FALSE;  // flag that indicates all schedulers should be forcibly shutdown
  gboolean ki_shut  = FALSE;  // flag that indicates all schedulers should be gracefully shutdown
  gboolean db_init  = FALSE;  // flag indicating a database test
  gboolean test_die = FALSE;  // flag to run the tests then die
  gboolean s_daemon = FALSE;  // falg to run the scheduler as a daemon
  gchar* logdir = NULL;       // used when a different log from the default is used
  GOptionContext* options;    // option context used for command line parsing
  GError* error = NULL;       // error object used during parsing
  uint16_t port = 0;
  gchar* sysconfigdir = DEFAULT_SETUP;

  /* THE SCHEDULER */
  scheduler_t* scheduler;

  if(getenv("FO_SYSCONFDIR") != NULL)
    sysconfigdir = getenv("FO_SYSCONFDIR");

  /* get this done first */
  srand(time(NULL));
#if !(GLIB_MAJOR_VERSION >= 2 && GLIB_MINOR_VERSION >= 32)
  g_thread_init(NULL);
#endif
#if !(GLIB_MAJOR_VERSION >= 2 && GLIB_MINOR_VERSION >= 36)
  g_type_init();
#endif

  /* the options for the command line parser */
  GOptionEntry entries[] =
  {
      { "daemon",   'd', 0, G_OPTION_ARG_NONE,   &s_daemon,     "      Run scheduler as daemon"                       },
      { "database", 'i', 0, G_OPTION_ARG_NONE,   &db_init,      "      Initialize database connection and exit"       },
      { "kill",     'k', 0, G_OPTION_ARG_NONE,   &ki_kill,      "      Forcibly kills all running schedulers"         },
      { "shutdown", 's', 0, G_OPTION_ARG_NONE,   &ki_shut,      "      Gracefully shutdown of all running schedulers" },
      { "log",      'L', 0, G_OPTION_ARG_STRING, &logdir,       "[str] Specify location of log file"                  },
      { "port",     'p', 0, G_OPTION_ARG_INT,    &port,         "[num] Set the interface port"                        },
      { "reset",    'R', 0, G_OPTION_ARG_NONE,   &db_reset,     "      Reset the job queue upon startup"              },
      { "test",     't', 0, G_OPTION_ARG_NONE,   &test_die,     "      Close the scheduler after running tests"       },
      { "verbose",  'v', 0, G_OPTION_ARG_INT,    &verbose,      "[num] Set the scheduler verbose level"               },
      { "config",   'c', 0, G_OPTION_ARG_STRING, &sysconfigdir, "[str] Specify system configuration directory"        },
      {NULL}
  };

  /* ********************* */
  /* *** parse options *** */
  /* ********************* */
  options = g_option_context_new("- scheduler for FOSSology");
  g_option_context_add_main_entries(options, entries, NULL);
  g_option_context_parse(options, &argc, &argv, &error);

  if(error)
  {
    fprintf(stderr, "ERROR: %s\n", error->message);
    fprintf(stderr, "%s", g_option_context_get_help(options, FALSE, NULL));
    fflush(stderr);
    return -1;
  }

  g_option_context_free(options);

  /* check changes to the process first */
  if(ki_shut) { return kill_scheduler(FALSE); }
  if(ki_kill) { return kill_scheduler(TRUE);  }

  /* initialize the scheduler */
  scheduler = scheduler_init(sysconfigdir,
      log_new("stdout", "initializing", getpid()));

  if(logdir)
  {
    scheduler->logdir     = logdir;
    scheduler->logcmdline = TRUE;
    scheduler->main_log   = log_new(scheduler->logdir, NULL, scheduler->s_pid);

    log_destroy(main_log);
    main_log = scheduler->main_log;
  }

  scheduler->process_name = g_strdup(argv[0]);
  scheduler->s_daemon     = s_daemon;

  scheduler_foss_config(scheduler);
  if(s_daemon && scheduler_daemonize(scheduler) == -1) { return -1; }
  scheduler_agent_config(scheduler);

  database_init(scheduler);
  email_init(scheduler);

  NOTIFY("*****************************************************************");
  NOTIFY("***                FOSSology scheduler started                ***");
  NOTIFY("***        pid:      %-33d        ***", getpid());
  NOTIFY("***        verbose:  %-33d        ***", verbose);
  NOTIFY("***        config:   %-33s        ***", sysconfigdir);
  NOTIFY("*****************************************************************");

  interface_init(scheduler);
  fo_RepOpenFull(scheduler->sysconfig);

  signal(SIGCHLD, scheduler_sig_handle);
  signal(SIGTERM, scheduler_sig_handle);
  signal(SIGQUIT, scheduler_sig_handle);
  signal(SIGHUP,  scheduler_sig_handle);

  /* ***************************************************** */
  /* *** we have finished initialization without error *** */
  /* ***************************************************** */

  if(db_reset)
    database_reset_queue(scheduler);
  if(test_die)
    closing = 1;
  event_loop_enter(scheduler, scheduler_update, scheduler_signal);

  NOTIFY("*****************************************************************");
  NOTIFY("***                FOSSology scheduler closed                 ***");
  NOTIFY("***        pid:     %-34d        ***", scheduler->s_pid);
  NOTIFY("*****************************************************************\n");

  interface_destroy(scheduler);
  scheduler_destroy(scheduler);
  return 0;
}