diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index 9550ff45e9acfca68c23320233542d63a8131101..d1cf4eba42ea398806b2b885acdfb945286eb7f7 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -46,6 +46,7 @@ #define BUF_SIZE 1024 time_t init_time; +log_options_t log_opts = LOG_OPTS_STDERR_ONLY ; slurm_ctl_conf_t slurmctld_conf; int msg_from_root (void); @@ -66,9 +67,8 @@ inline static void slurm_rpc_update_node ( slurm_msg_t * msg ) ; inline static void slurm_rpc_update_partition ( slurm_msg_t * msg ) ; inline static void slurm_rpc_job_will_run ( slurm_msg_t * msg ) ; inline static void slurm_rpc_job_step_create( slurm_msg_t* msg ) ; - inline static void slurm_rpc_allocate_resources ( slurm_msg_t * msg , uint8_t immediate ) ; - +void usage (char *prog_name); int main (int argc, char *argv[]) @@ -79,11 +79,9 @@ main (int argc, char *argv[]) slurm_msg_t * msg = NULL ; slurm_addr cli_addr ; char node_name[MAX_NAME_LEN]; - log_options_t opts = LOG_OPTS_STDERR_ONLY ; -/* log_options_t opts = { 1, LOG_LEVEL_DEBUG3, LOG_LEVEL_QUIET, LOG_LEVEL_QUIET } ; */ init_time = time (NULL); - log_init(argv[0], opts, SYSLOG_FACILITY_DAEMON, NULL); + log_init(argv[0], log_opts, SYSLOG_FACILITY_DAEMON, NULL); init_ctld_conf ( &slurmctld_conf ); parse_commandline ( argc, argv, &slurmctld_conf ); @@ -785,27 +783,19 @@ init_ctld_conf ( slurm_ctl_conf_t * conf_ptr ) conf_ptr->state_save_location = NULL ; conf_ptr->tmp_fs = NULL ; -#ifdef SLURMCTLD_PORT servent = getservbyname (SLURMCTLD_PORT, NULL); if (servent) conf_ptr->slurmctld_port = servent -> s_port; else conf_ptr->slurmctld_port = strtol (SLURMCTLD_PORT, (char **) NULL, 10); endservent (); -#else - conf_ptr->slurmctld_port = 0 ; -#endif -#ifdef SLURMD_PORT servent = getservbyname (SLURMD_PORT, NULL); if (servent) conf_ptr->slurmd_port = servent -> s_port; else conf_ptr->slurmd_port = strtol (SLURMD_PORT, (char **) NULL, 10); endservent (); -#else - conf_ptr->slurmd_port = 0 ; -#endif } @@ -839,30 +829,65 @@ extern int optind, opterr, optopt; void parse_commandline( int argc, char* argv[], slurm_ctl_conf_t * conf_ptr ) { - int c = 0; + int c = 0, errlev; opterr = 0; - while ((c = getopt (argc, argv, "b:c:f:s")) != -1) + while ((c = getopt (argc, argv, "e:f:hl:s:")) != -1) switch (c) { - case 'b': - conf_ptr->backup_controller = optarg; - printf("backup_controller = %s\n", conf_ptr->backup_controller ); + case 'e': + errlev = strtol (optarg, (char **) NULL, 10); + if ((errlev < LOG_LEVEL_QUIET) || + (errlev > LOG_LEVEL_DEBUG3)) { + fprintf (stderr, "invalid errlev argument\n"); + usage (argv[0]); + exit (1); + } + log_opts . stderr_level = errlev; break; - case 'c': - conf_ptr->control_machine = optarg; - printf("control_machine = %s\n", conf_ptr->control_machine ); + case 'h': + usage (argv[0]); + exit (0); break; case 'f': slurmctld_conf.slurm_conf = optarg; - printf("slurmctrld.conf = %s\n", slurmctld_conf.slurm_conf ); + printf("slurmctrld.slurm_conf = %s\n", slurmctld_conf.slurm_conf ); + break; + case 'l': + errlev = strtol (optarg, (char **) NULL, 10); + if ((errlev < LOG_LEVEL_QUIET) || + (errlev > LOG_LEVEL_DEBUG3)) { + fprintf (stderr, "invalid errlev argument\n"); + usage (argv[0]); + exit (1); + } + log_opts . logfile_level = errlev; break; case 's': - conf_ptr->fast_schedule = 1; + errlev = strtol (optarg, (char **) NULL, 10); + if ((errlev < LOG_LEVEL_QUIET) || + (errlev > LOG_LEVEL_DEBUG3)) { + fprintf (stderr, "invalid errlev argument\n"); + usage (argv[0]); + exit (1); + } + log_opts . syslog_level = errlev; break; default: - abort (); + usage (argv[0]); + exit (1); } + log_init(argv[0], log_opts, SYSLOG_FACILITY_DAEMON, NULL); +} +void +usage (char *prog_name) +{ + printf ("%s [OPTIONS]\n", prog_name); + printf (" -e <errlev> Set stderr logging to the specified level\n"); + printf (" -f <file> Use specified configuration file name\n"); + printf (" -l <errlev> Set logfile logging to the specified level\n"); + printf (" -s <errlev> Set syslog logging to the specified level\n"); + printf ("<errlev> is an integer between 0 and 7 with higher numbers providing more detail.\n"); } diff --git a/src/slurmctld/read_config.c b/src/slurmctld/read_config.c index e539b5023fe4e40919b77f83e5481710776c6d6a..7db4cb1ae22cbd2a8e0b2aabcc3d9050774b84ec 100644 --- a/src/slurmctld/read_config.c +++ b/src/slurmctld/read_config.c @@ -11,6 +11,7 @@ #include <ctype.h> #include <errno.h> +#include <netdb.h> #include <stdio.h> #include <string.h> #include <syslog.h> @@ -675,18 +676,21 @@ read_slurm_conf ( ) { int i, j, error_code; char *backup_controller = NULL, *control_machine = NULL, *epilog = NULL; char *prioritize = NULL, *prolog = NULL, *state_save_location = NULL, *tmp_fs = NULL; + char *slurmctld_port = NULL, *slurmd_port = NULL; int fast_schedule = 0, hash_base = 0, heartbeat_interval = 0, kill_wait = 0; - int slurmctld_port = 0, slurmctld_timeout = 0, slurmd_port = 0; + int slurmctld_timeout = 0; int slurmd_timeout = 0; long first_job_id = 0; + struct servent *servent; /* initialization */ start_time = clock (); - slurm_spec_file = fopen (SLURM_CONFIG_FILE, "r"); + slurm_spec_file = fopen (slurmctld_conf.slurm_conf, "r"); if (slurm_spec_file == NULL) - fatal ("read_slurm_conf error %d opening file %s", errno, SLURM_CONFIG_FILE); + fatal ("read_slurm_conf error %d opening file %s", + errno, slurmctld_conf.slurm_conf); - info ("read_slurm_conf: loading configuration from %s", SLURM_CONFIG_FILE); + info ("read_slurm_conf: loading configuration from %s", slurmctld_conf.slurm_conf); /* process the data file */ line_num = 0; @@ -695,7 +699,7 @@ read_slurm_conf ( ) { line_num++; if (strlen (in_line) >= (BUF_SIZE - 1)) { error ("read_slurm_conf line %d, of input file %s too long\n", - line_num, SLURM_CONFIG_FILE); + line_num, slurmctld_conf.slurm_conf); fclose (slurm_spec_file); return E2BIG; break; @@ -731,9 +735,9 @@ read_slurm_conf ( ) { "KillWait=", 'd', &kill_wait, "Prioritize=", 's', &prioritize, "Prolog=", 's', &prolog, - "SlurmctldPort=", 'd', &slurmctld_port, + "SlurmctldPort=", 's', &slurmctld_port, "SlurmctldTimeout=", 'd', &slurmctld_timeout, - "SlurmdPort=", 'd', &slurmd_port, + "SlurmdPort=", 's', &slurmd_port, "SlurmdTimeout=", 'd', &slurmd_timeout, "StateSaveLocation=", 's', &state_save_location, "TmpFS=", 's', &tmp_fs, @@ -790,16 +794,24 @@ read_slurm_conf ( ) { prolog = NULL; } if ( slurmctld_port ) { - slurmctld_conf.slurmctld_port = slurmctld_port; - slurmctld_port = 0; + servent = getservbyname (slurmctld_port, NULL); + if (servent) + slurmctld_conf.slurmctld_port = servent -> s_port; + else + slurmctld_conf.slurmctld_port = strtol (slurmctld_port, (char **) NULL, 10); + endservent (); } if ( slurmctld_timeout ) { slurmctld_conf.slurmctld_timeout = slurmctld_timeout; slurmctld_timeout = 0; } if ( slurmd_port ) { - slurmctld_conf.slurmd_port = slurmd_port; - slurmd_port = 0; + servent = getservbyname (slurmd_port, NULL); + if (servent) + slurmctld_conf.slurmd_port = servent -> s_port; + else + slurmctld_conf.slurmd_port = strtol (slurmd_port, (char **) NULL, 10); + endservent (); } if ( slurmd_timeout ) { slurmctld_conf.slurmd_timeout = slurmd_timeout;