فهرست منبع

Implement config file testing mode

Signed-off-by: Vladislav Bogdanov <bubble@hoster-ok.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Vladislav Bogdanov 11 سال پیش
والد
کامیت
e3ffd4fedc
2فایلهای تغییر یافته به همراه18 افزوده شده و 4 حذف شده
  1. 15 4
      exec/main.c
  2. 3 0
      man/corosync.8

+ 15 - 4
exec/main.c

@@ -1190,7 +1190,7 @@ int main (int argc, char **argv, char **envp)
 	const char *error_string;
 	const char *error_string;
 	struct totem_config totem_config;
 	struct totem_config totem_config;
 	int res, ch;
 	int res, ch;
-	int background, setprio;
+	int background, setprio, testonly;
 	struct stat stat_out;
 	struct stat stat_out;
 	enum e_corosync_done flock_err;
 	enum e_corosync_done flock_err;
 	uint64_t totem_config_warnings;
 	uint64_t totem_config_warnings;
@@ -1200,8 +1200,9 @@ int main (int argc, char **argv, char **envp)
 	 */
 	 */
 	background = 1;
 	background = 1;
 	setprio = 0;
 	setprio = 0;
+	testonly = 0;
 
 
-	while ((ch = getopt (argc, argv, "fprv")) != EOF) {
+	while ((ch = getopt (argc, argv, "fprtv")) != EOF) {
 
 
 		switch (ch) {
 		switch (ch) {
 			case 'f':
 			case 'f':
@@ -1212,6 +1213,9 @@ int main (int argc, char **argv, char **envp)
 			case 'r':
 			case 'r':
 				setprio = 1;
 				setprio = 1;
 				break;
 				break;
+			case 't':
+				testonly = 1;
+				break;
 			case 'v':
 			case 'v':
 				printf ("Corosync Cluster Engine, version '%s'\n", VERSION);
 				printf ("Corosync Cluster Engine, version '%s'\n", VERSION);
 				printf ("Copyright (c) 2006-2009 Red Hat, Inc.\n");
 				printf ("Copyright (c) 2006-2009 Red Hat, Inc.\n");
@@ -1224,6 +1228,7 @@ int main (int argc, char **argv, char **envp)
 					"usage:\n"\
 					"usage:\n"\
 					"        -f     : Start application in foreground.\n"\
 					"        -f     : Start application in foreground.\n"\
 					"        -p     : Does nothing.    \n"\
 					"        -p     : Does nothing.    \n"\
+					"        -t     : Test configuration and exit.\n"\
 					"        -r     : Set round robin realtime scheduling \n"\
 					"        -r     : Set round robin realtime scheduling \n"\
 					"        -v     : Display version and SVN revision of Corosync and exit.\n");
 					"        -v     : Display version and SVN revision of Corosync and exit.\n");
 				logsys_system_fini();
 				logsys_system_fini();
@@ -1283,8 +1288,10 @@ int main (int argc, char **argv, char **envp)
 		corosync_exit_error (COROSYNC_DONE_LOGCONFIGREAD);
 		corosync_exit_error (COROSYNC_DONE_LOGCONFIGREAD);
 	}
 	}
 
 
-	log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine ('%s'): started and ready to provide service.", VERSION);
-	log_printf (LOGSYS_LEVEL_INFO, "Corosync built-in features:" PACKAGE_FEATURES "");
+	if (!testonly) {
+		log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine ('%s'): started and ready to provide service.", VERSION);
+		log_printf (LOGSYS_LEVEL_INFO, "Corosync built-in features:" PACKAGE_FEATURES "");
+	}
 
 
 	/*
 	/*
 	 * Make sure required directory is present
 	 * Make sure required directory is present
@@ -1336,6 +1343,10 @@ int main (int argc, char **argv, char **envp)
 		corosync_exit_error (COROSYNC_DONE_MAINCONFIGREAD);
 		corosync_exit_error (COROSYNC_DONE_MAINCONFIGREAD);
 	}
 	}
 
 
+	if (testonly) {
+		corosync_exit_error (COROSYNC_DONE_EXIT);
+	}
+
 	ip_version = totem_config.ip_version;
 	ip_version = totem_config.ip_version;
 
 
 	totem_config.totem_memb_ring_id_create_or_load = corosync_ring_id_create_or_load;
 	totem_config.totem_memb_ring_id_create_or_load = corosync_ring_id_create_or_load;

+ 3 - 0
man/corosync.8

@@ -50,6 +50,9 @@ Does nothing (was: "Do not set process priority" - this is now the default).
 .B -r
 .B -r
 Set round robin realtime scheduling.
 Set round robin realtime scheduling.
 .TP
 .TP
+.B -t
+Test configuration and then exit.
+.TP
 .B -v
 .B -v
 Display version and SVN revision of Corosync and exit.
 Display version and SVN revision of Corosync and exit.
 .SH SEE ALSO
 .SH SEE ALSO