eliminate initial configure(use command line options)
This commit is contained in:
parent
41f56fa6ed
commit
9f91f3df80
4 changed files with 1 additions and 54 deletions
|
|
@ -13,7 +13,6 @@ static char doc[] = "xce_controller";
|
||||||
static char args_doc[] = "";
|
static char args_doc[] = "";
|
||||||
const char* argp_program_version = MK_VERSION("xce v0.0.1-", STR(VERSION_COMMIT_ID));
|
const char* argp_program_version = MK_VERSION("xce v0.0.1-", STR(VERSION_COMMIT_ID));
|
||||||
const char* argp_program_bug_address = BUG_EMAIL;
|
const char* argp_program_bug_address = BUG_EMAIL;
|
||||||
static char* default_config = "/tmp/xce/xce.yaml";
|
|
||||||
|
|
||||||
struct arguments {
|
struct arguments {
|
||||||
char* config;
|
char* config;
|
||||||
|
|
@ -90,7 +89,6 @@ static char* verbose_to_loglevel(int verbose)
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
struct arguments arguments;
|
struct arguments arguments;
|
||||||
initial_config_t* init_config;
|
|
||||||
myconf_t myconf;
|
myconf_t myconf;
|
||||||
char* logdir = "/tmp";
|
char* logdir = "/tmp";
|
||||||
char* loglevel = "info";
|
char* loglevel = "info";
|
||||||
|
|
@ -107,10 +105,6 @@ int main(int argc, char* argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments.config == NULL) {
|
|
||||||
arguments.config = default_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments.logdir != NULL) {
|
if (arguments.logdir != NULL) {
|
||||||
logdir = arguments.logdir;
|
logdir = arguments.logdir;
|
||||||
}
|
}
|
||||||
|
|
@ -121,41 +115,11 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
mylog_init(logdir, myname, loglevel, logsize, logcount);
|
mylog_init(logdir, myname, loglevel, logsize, logcount);
|
||||||
|
|
||||||
load_initial_config(arguments.config,
|
|
||||||
&init_config,
|
|
||||||
arguments.verbose);
|
|
||||||
|
|
||||||
if (init_config == NULL) {
|
|
||||||
tlog_error("Fail to read initial log");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
myconf.init_config = init_config;
|
|
||||||
myconf.cluster_config = NULL;
|
myconf.cluster_config = NULL;
|
||||||
myconf.conffile = arguments.clusterconf;
|
myconf.conffile = arguments.clusterconf;
|
||||||
|
|
||||||
if (init_config != NULL) {
|
|
||||||
if (init_config->logging != NULL) {
|
|
||||||
if ((init_config->logging->logdir != NULL) && (arguments.logdir == NULL)) {
|
|
||||||
char logfile[XCE_MAXPATH_LEN + 1];
|
|
||||||
|
|
||||||
logdir = init_config->logging->logdir;
|
|
||||||
snprintf(logfile, sizeof(logfile) - 1,
|
|
||||||
"%s/%s.log", logdir, myname);
|
|
||||||
|
|
||||||
tlog_set_logfile(logfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((init_config->logging->loglevel != NULL) && (arguments.verbose == 0)) {
|
|
||||||
loglevel = init_config->logging->loglevel;
|
|
||||||
|
|
||||||
mylog_setlevel(loglevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
myapp_run(&myconf);
|
myapp_run(&myconf);
|
||||||
|
|
||||||
free_initial_config(init_config);
|
|
||||||
mylog_fini();
|
mylog_fini();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -161,13 +161,3 @@ cluster_config_t* get_default_conf(void* cl)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_initial_config(char* file,
|
|
||||||
initial_config_t** conf,
|
|
||||||
int verbose)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_initial_config(initial_config_t* conf)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
};
|
};
|
||||||
in rec {
|
in rec {
|
||||||
packages = pkgs // xpkgs;
|
packages = pkgs // xpkgs;
|
||||||
defaultPackage = xpkgs.xce_withoutdb_debug;
|
defaultPackage = xpkgs.xce_debug;
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
nativeBuildInputs = xpkgs.xce.nativeBuildInputs;
|
nativeBuildInputs = xpkgs.xce.nativeBuildInputs;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,18 +14,11 @@ struct logging {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct logging* logging;
|
|
||||||
} initial_config_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
initial_config_t* init_config;
|
|
||||||
cluster_config_t* cluster_config;
|
cluster_config_t* cluster_config;
|
||||||
char* conffile;
|
char* conffile;
|
||||||
} myconf_t;
|
} myconf_t;
|
||||||
|
|
||||||
extern cluster_config_t* get_default_conf(void*);
|
extern cluster_config_t* get_default_conf(void*);
|
||||||
extern int add_config(void*, char*, char*);
|
extern int add_config(void*, char*, char*);
|
||||||
extern int load_initial_config(char*, initial_config_t**, int);
|
|
||||||
extern void free_initial_config(initial_config_t*);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue