Ejemplo n.º 1
0
bool ServerRunner::stopAfterExecutingOptions_() {
    if (options_.count("help")) {
        std::cout << optionsDescription_ << std::endl;
        return true;
    }

    if (options_.count("version")) {
        std::cout << get_psi_toolkit_version_string() << std::endl;
        return true;
    }

    if (setRootDirectory_() != 0)
        return true;

    if (options_.count("log-file")) {
        SET_LOGGER_FILE(options_["log-file"].as<std::string>());
    }

    if (options_.count("log-level")) {
        SET_LOGGING_LEVEL(options_["log-level"].as<std::string>());
    }


    if (options_.count("daemon"))
        daemonize_(options_.count("leave-standard-descriptors-when-daemonizing") > 0);

    return false;
}
Ejemplo n.º 2
0
void
init_res (void)
{
  static char fname[] = "init_res";
  int i, maxfds;

  if (logclass & (LC_TRACE | LC_HANG))
    ls_syslog (LOG_DEBUG, "%s: Entering this routine...", fname);



  if (!sbdMode)
    {
      if (!debug)
	{

	  if (geteuid () || getuid ())
	    {
	      fprintf (stderr, "RES should be run as root.\n");
	      fflush (stderr);
	      resExit_ (1);
	    }



	  chdir ("/tmp");
	}



      if (debug <= 1)
	{

	  daemonize_ ();



	  ls_openlog ("res", resParams[LSF_LOGDIR].paramValue, 0,
		      resParams[LSF_LOG_MASK].paramValue);



	  umask (0);





	  nice (NICE_LEAST);
	}
    }

  if ((Myhost = ls_getmyhostname ()) == NULL)
    {
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL_MM, fname, "ls_getmyhostname");
      resExit_ (-1);
    }


  if (isatty (0))
    {
      tcgetattr (0, &defaultTty.attr);

      defaultTty.ws.ws_row = 24;
      defaultTty.ws.ws_col = 80;
      defaultTty.ws.ws_xpixel = defaultTty.ws.ws_ypixel = 0;
    }
  else
    {
      defaultTty.ws.ws_row = 24;
      defaultTty.ws.ws_col = 80;
      defaultTty.ws.ws_xpixel = defaultTty.ws.ws_ypixel = 0;
    }

  if (!sbdMode)
    {

      init_AcceptSock ();
    }

  client_cnt = child_cnt = 0;

  for (i = 0; i < MAXCLIENTS_HIGHWATER_MARK + 1; i++)
    {
      clients[i] = NULL;
    }

  children =
    (struct child **) calloc (sysconf (_SC_OPEN_MAX),
			      sizeof (struct children *));
  if (!children)
    {
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL_M, fname, "calloc");
      resExit_ (-1);
    }

  maxfds = sysconf (_SC_OPEN_MAX);

  for (i = 0; i < maxfds; i++)
    {
      children[i] = NULL;
    }

  initConn2NIOS ();
  resNotifyList = listCreate ("resNotifyList");
  if (!resNotifyList)
    {
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL_M, fname, "listCreate");
      resExit_ (-1);
    }




  ls_syslog (LOG_INFO, (_i18n_msg_get (ls_catd, NL_SETN, 5346, "Daemon started")));	/* catgets 5346 */

  initResLog ();

}