Some issues about the function main_ctx_init
- The length of the macro MAX_PATH is only 260, isn't it really too small?
- The logdir directly reads the running directory, then creates and uses the directory logs in this directory. Even if the directory was modified later, an empty directory has already been created here.
- The configuration file directory should have a rollback: first try the current directory (not the current directory/etc), then try the directory /usr/local/etc if it does not exist, and finally try the directory /etc.
The main issue is that the directory will be automatically created before customizing the path.
There is another issue, in lines 87 to 90 of the file base/main. c, the following log file path don't use the variable logdir
你这问题和我之前遇到的有些类似,我当时提的issue 可惜作者说 可以在main_ctx_init后自行再重新设置conf/pid/log等路径(不过我确实没看出怎么在不调整main_ctx_init逻辑的情况仅更改自定义目录) [并且属于定制化改造需求只能自己维护fork。最终我的fork版改造如下
There is another issue, in lines 87 to 90 of the file base/main. c, the following log file path don't use the variable logdir
你说的应该是这个logdir,目的就只是为了尝试创建个目录,只不过后面又用snprintf和logdir同样的方式+文件名保存到g_main_ctx.logfile,也并非没有用到logdir
char logdir[MAX_PATH] = {0};
snprintf(logdir, sizeof(logdir), "%s/logs", g_main_ctx.run_dir);
hv_mkdir(logdir);