reshape controller startup

This commit is contained in:
Rongsong Shen 2025-11-06 17:17:26 +08:00
parent 9f91f3df80
commit a665ccd4fe
5 changed files with 32 additions and 33 deletions

View file

@ -15,17 +15,15 @@ const char* argp_program_version = MK_VERSION("xce v0.0.1-", STR(VERSION_CO
const char* argp_program_bug_address = BUG_EMAIL;
struct arguments {
char* config;
char* logdir;
char* clusterconf;
char* logfile;
char* workdir;
int verbose;
};
static struct argp_option options[] = {
{ "config", 'c', "FILE", 0, "Load initial configuration from FILE" },
{ "logdir", 'd', "DIR", 0, "Directory for log file" },
{ "workdir", 'w', "DIR", 0, "The work directory of xce controller"},
{ "logfile", 'l', "FILE", 0, "The full path of log file" },
{ "verbose", 'v', 0, 0, "Produce verbose logs" },
{ "clusterconf", 'f', "FILE", 0, "Load Cluster Configuration from FILE" },
{ 0 }
};
@ -36,17 +34,14 @@ static error_t parse_opt(int key,
struct arguments* arguments = state->input;
switch (key) {
case 'c':
arguments->config = arg;
break;
case 'd':
arguments->logdir = arg;
case 'l':
arguments->logfile = arg;
break;
case 'v':
arguments->verbose++;
break;
case 'f':
arguments->clusterconf = arg;
case 'w':
arguments->workdir = arg;
break;
default:
return ARGP_ERR_UNKNOWN;
@ -90,33 +85,39 @@ int main(int argc, char* argv[])
{
struct arguments arguments;
myconf_t myconf;
char* logdir = "/tmp";
char* logfile = "/tmp/xce_controller.log";
char* loglevel = "info";
int logsize = 64 * 1024 * 1024;
int logcount = 10;
char* myname = "xce_controller";
char conf_file[XCE_MAXPATH_LEN+1];
memset(&arguments, 0x0, sizeof(arguments));
argp_parse(&argp, argc, argv, 0, 0, &arguments);
if (arguments.clusterconf == NULL) {
tlog_error("no cluster configuration specified. please use -f to specify cluster configuration file");
return -1;
}
if (arguments.logdir != NULL) {
logdir = arguments.logdir;
if (arguments.logfile != NULL) {
logfile = arguments.logfile;
}
if (arguments.verbose != 0) {
loglevel = verbose_to_loglevel(arguments.verbose);
}
mylog_init(logdir, myname, loglevel, logsize, logcount);
mylog_init(logfile, loglevel, logsize, logcount);
if (arguments.workdir == NULL) {
INFO("no cluster work directory specified. The default work directory `"
DEFAULT_WORKDIR
"' will be used.");
arguments.workdir = DEFAULT_WORKDIR;
}
memset(&conf_file, 0x0, sizeof(conf_file));
snprintf(conf_file, XCE_MAXPATH_LEN,
"%s/conf/current_config", arguments.workdir);
myconf.cluster_config = NULL;
myconf.conffile = arguments.clusterconf;
myconf.conffile = conf_file;
myapp_run(&myconf);