Version 0.0.1 removed old code.

This commit is contained in:
unrealdragon 2026-05-14 15:49:52 +05:30
commit 7e8c45e88e

View file

@ -56,14 +56,11 @@ void parseConfig() {
if(file_in.eof())
break;
ss << data;
std::cout << data;
}
std::cout << std::endl;
json config = json::parse(ss.str());
if(config.find("log_file_max_size") != config.end() && config["log_file_max_size"].is_number_integer()) {
options.log_file_max_size = config["log_file_max_size"].get<long long int>();
}
std::cout << "Log file max size: " << options.log_file_max_size << std::endl;
}
std::string strip(std::string& t) {
@ -105,15 +102,15 @@ void printJsonHelp() {
std::cout << "Json StartUp List file format: " << std::endl;
std::cout << "Top level is an Array of Apps." << std::endl;
std::cout << "Each App Entry contains: " << std::endl;
std::cout << "\tname[string] : Name of the module." << std::endl;
std::cout << "\tapp_name[string] : Path to the program with its name." << std::endl;
std::cout << "\tapp_args[list[string]] : List of arguments to the program." << std::endl;
std::cout << "\trun_mode[string] : Mode can be daemon or script." << std::endl;
std::cout << "\t[REQUIRED] name[string] : Name of the module." << std::endl;
std::cout << "\t[REQUIRED] app_name[string] : Path to the program with its name." << std::endl;
std::cout << "\t[OPTIONAL] app_args[list[string]] : List of arguments to the program." << std::endl;
std::cout << "\t[REQUIRED] run_mode[string] : Mode can be daemon or script." << std::endl;
std::cout << "\t\tMode daemon: The app forks the program and exits without waiting." << std::endl;
std::cout << "\t\tMode script: The app forks the program and waits for it to finish execution." << std::endl;
std::cout << "\t\tMode script: If no run_mode is given it is presumed to be script." << std::endl;
std::cout << "\tworking_dir[string] : Working directory of the program." << std::endl;
std::cout << "\tcreate_log[boolean] : Create a log file at logs path." << std::endl;
std::cout << "\t[OPTIONAL] working_dir[string] : Working directory of the program." << std::endl;
std::cout << "\t[OPTIONAL] create_log[boolean] : Create a log file at logs path." << std::endl;
std::cout << std::endl << "Example startup_apps.json: ";
std::cout << R"(
[
@ -235,49 +232,6 @@ void parseArgs(int c, char *v[]) {
}
}
// void forkAndWait(std::string program_name, std::string name, std::string args, std::string dir, bool bash = false) {
// auto pid = fork();
// switch(pid) {
// case 0: {
// if(!dir.empty()) {
// int err = chdir(dir.c_str());
// if(err != 0) {
// std::cout << "Child changing dir failed: " << err << std::endl;
// }
// }
// std::cout << "Child running: " << program_name << " with args: " << args;
// if(bash)
// execl(program_name.c_str(), program_name.c_str(), "-c", args.c_str(), (char *)NULL);
// else
// execl(program_name.c_str(), program_name.c_str(), args.c_str(), (char *)NULL);
// exit(0);
// }
// default: {
// int status;
// int wait = waitpid(pid, &status, WUNTRACED);
// std::cout << "Parent wait finished: " << wait << " child status: " << status << std::endl;
// }
// }
// }
// void forkAndContinue(std::string program_name, std::string name, std::string args, std::string dir, bool bash = false) {
// auto pid = fork();
// if(pid == 0) {
// if(!dir.empty()) {
// int err = chdir(dir.c_str());
// if(err != 0) {
// std::cout << "Child changing dir failed: " << err << std::endl;
// }
// }
// std::cout << "Child running: " << program_name << " with args: " << args;
// if(bash)
// execl(program_name.c_str(), program_name.c_str(), "-c", args.c_str(), (char *)NULL);
// else
// execl(program_name.c_str(), program_name.c_str(), args.c_str(), (char *)NULL);
// exit(0);
// }
// }
std::string string_strip(std::string str) {
std::string ch;
bool front_found = false;
@ -450,7 +404,9 @@ int main(int argc, char *argv[]) {
Log log_file(log_file_path, options.log_file_max_size);
std::cout << "Starter Init: Log file path: " << log_file_path << std::endl;
std::cout << "Log file open: " << log_file.isOpen() << std::endl;
log_file << "-------- Starting app: " << get_current_time();
log_file << "-------- Starting app --------" << std::endl;
log_file << "Current Time: " << get_current_time();
log_file << "Log file max size: " << options.log_file_max_size << std::endl;
log_file << "Current path: " << std::filesystem::current_path() << std::endl;
std::string json_file_path = json_path;
if(std::filesystem::is_directory(json_path)) {