From 9f91f3df80debf5418fc7bef0e6a43388303af6c Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Thu, 6 Nov 2025 16:12:02 +0800 Subject: [PATCH] eliminate initial configure(use command line options) --- src/controller/main.c | 36 ------------------------------------ src/controller/myconf.c | 10 ---------- src/flake.nix | 2 +- src/include/myconf.h | 7 ------- 4 files changed, 1 insertion(+), 54 deletions(-) diff --git a/src/controller/main.c b/src/controller/main.c index eb176af..051afb5 100644 --- a/src/controller/main.c +++ b/src/controller/main.c @@ -13,7 +13,6 @@ static char doc[] = "xce_controller"; static char args_doc[] = ""; const char* argp_program_version = MK_VERSION("xce v0.0.1-", STR(VERSION_COMMIT_ID)); const char* argp_program_bug_address = BUG_EMAIL; -static char* default_config = "/tmp/xce/xce.yaml"; struct arguments { char* config; @@ -90,7 +89,6 @@ static char* verbose_to_loglevel(int verbose) int main(int argc, char* argv[]) { struct arguments arguments; - initial_config_t* init_config; myconf_t myconf; char* logdir = "/tmp"; char* loglevel = "info"; @@ -107,10 +105,6 @@ int main(int argc, char* argv[]) return -1; } - if (arguments.config == NULL) { - arguments.config = default_config; - } - if (arguments.logdir != NULL) { logdir = arguments.logdir; } @@ -121,41 +115,11 @@ int main(int argc, char* argv[]) 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.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); - free_initial_config(init_config); mylog_fini(); return 0; diff --git a/src/controller/myconf.c b/src/controller/myconf.c index 0081112..d422678 100644 --- a/src/controller/myconf.c +++ b/src/controller/myconf.c @@ -161,13 +161,3 @@ cluster_config_t* get_default_conf(void* cl) return c; } -int load_initial_config(char* file, - initial_config_t** conf, - int verbose) -{ - return 0; -} - -void free_initial_config(initial_config_t* conf) -{ -} diff --git a/src/flake.nix b/src/flake.nix index 184282c..df2457d 100644 --- a/src/flake.nix +++ b/src/flake.nix @@ -27,7 +27,7 @@ }; in rec { packages = pkgs // xpkgs; - defaultPackage = xpkgs.xce_withoutdb_debug; + defaultPackage = xpkgs.xce_debug; devShells.default = pkgs.mkShell { nativeBuildInputs = xpkgs.xce.nativeBuildInputs; }; diff --git a/src/include/myconf.h b/src/include/myconf.h index 84b5874..6e10f95 100644 --- a/src/include/myconf.h +++ b/src/include/myconf.h @@ -14,18 +14,11 @@ struct logging { }; typedef struct { - struct logging* logging; -} initial_config_t; - -typedef struct { - initial_config_t* init_config; cluster_config_t* cluster_config; char* conffile; } myconf_t; extern cluster_config_t* get_default_conf(void*); 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