133 lines
4.0 KiB
C++
133 lines
4.0 KiB
C++
/*************************************************************************
|
|
> File Name : CConfig.h
|
|
> Author : FengChao
|
|
> EMail : smile.fengchao@gmail.com
|
|
> Created Time : Fri 17 Jul 2020 09:31:50 AM CST
|
|
************************************************************************/
|
|
|
|
#include <iostream>
|
|
#include <stdio.h>
|
|
#include <string>
|
|
#include <string.h>
|
|
#include "CJudgeUtils.h"
|
|
#include "CTypedef.h"
|
|
|
|
class Config : public CSingleton<Config>
|
|
{
|
|
public:
|
|
Config() {}
|
|
virtual ~Config() {}
|
|
public:
|
|
|
|
void Init(const std::string& file_name)
|
|
{
|
|
INIReader reader;
|
|
reader.Parse(file_name);
|
|
|
|
std::string strNosIdx;
|
|
for(int i = 0; i < NOS_MAX_NUM; i++)
|
|
{
|
|
strNosIdx.clear();
|
|
strNosIdx = "nos" + std::to_string((i + 1)) + "_ip";
|
|
nos_ip[i] = reader.Get("judge", strNosIdx, strNosIdx);
|
|
}
|
|
|
|
#define _GET_JUDGE_CFG(value) value = reader.GetInt32("judge", #value, value)
|
|
_GET_JUDGE_CFG(schedule_port);
|
|
_GET_JUDGE_CFG(pluginsctrl_port);
|
|
_GET_JUDGE_CFG(sub_nos_state_port);
|
|
_GET_JUDGE_CFG(nos_num);
|
|
_GET_JUDGE_CFG(running_num);
|
|
|
|
#undef _GET_JUDGE_CFG
|
|
|
|
#define _GET_JUDGE_CFG(value) value = reader.Get("judge", #value, value)
|
|
_GET_JUDGE_CFG(config_manager_ip);
|
|
_GET_JUDGE_CFG(schedule_ip);
|
|
_GET_JUDGE_CFG(pluginsctrl_ip);
|
|
|
|
#undef _GET_JUDGE_CFG
|
|
|
|
// Judge_sys_info
|
|
#define _GET_JUDGE_SYS_INFO_CFG(value) value = reader.GetInt32("judge_sys_info", #value, value)
|
|
_GET_JUDGE_SYS_INFO_CFG(nos_report_port);
|
|
_GET_JUDGE_SYS_INFO_CFG(msg_time_out);
|
|
_GET_JUDGE_SYS_INFO_CFG(cpu_occupy_max);
|
|
_GET_JUDGE_SYS_INFO_CFG(mem_occupy_max);
|
|
_GET_JUDGE_SYS_INFO_CFG(tcp_socket_max);
|
|
_GET_JUDGE_SYS_INFO_CFG(process_max);
|
|
_GET_JUDGE_SYS_INFO_CFG(cron_max);
|
|
_GET_JUDGE_SYS_INFO_CFG(path_file_max);
|
|
_GET_JUDGE_SYS_INFO_CFG(home_file_max);
|
|
_GET_JUDGE_SYS_INFO_CFG(process_running_code);
|
|
|
|
#undef _GET_JUDGE_SYS_INFO_CFG
|
|
|
|
#define _GET_JUDGE_SYS_INFO_CFG(value) value = reader.Get("judge_sys_info", #value, value)
|
|
_GET_JUDGE_SYS_INFO_CFG(sys_shell_log_name);
|
|
_GET_JUDGE_SYS_INFO_CFG(sys_login_log_name);
|
|
_GET_JUDGE_SYS_INFO_CFG(user_md5);
|
|
_GET_JUDGE_SYS_INFO_CFG(group_md5);
|
|
_GET_JUDGE_SYS_INFO_CFG(config_manager_md5);
|
|
_GET_JUDGE_SYS_INFO_CFG(auto_start_md5);
|
|
_GET_JUDGE_SYS_INFO_CFG(process_manager_name);
|
|
_GET_JUDGE_SYS_INFO_CFG(process_protocol_name);
|
|
_GET_JUDGE_SYS_INFO_CFG(process_local_cfgm_name);
|
|
_GET_JUDGE_SYS_INFO_CFG(process_firewall_name);
|
|
|
|
#undef _GET_JUDGE_SYS_INFO_CFG
|
|
|
|
#define _GET_JUDGE_CFG(value) value = reader.GetInt32("trans", #value, value)
|
|
_GET_JUDGE_CFG(trans_send_port);
|
|
_GET_JUDGE_CFG(trans_recv_port);
|
|
|
|
#undef _GET_JUDGE_CFG
|
|
|
|
#define _GET_JUDGE_CFG(value) value = reader.Get("trans", #value, value)
|
|
_GET_JUDGE_CFG(trans_send_ip);
|
|
|
|
#undef _GET_JUDGE_CFG
|
|
}
|
|
|
|
std::string nos_ip[NOS_MAX_NUM];
|
|
std::string config_manager_ip;
|
|
std::string schedule_ip;
|
|
std::string pluginsctrl_ip;
|
|
|
|
std::string trans_send_ip;
|
|
|
|
int sub_nos_state_port;
|
|
int schedule_port;
|
|
int pluginsctrl_port;
|
|
int nos_num;
|
|
int running_num;
|
|
|
|
// Judge_sys_info
|
|
std::string sys_shell_log_name;
|
|
std::string sys_login_log_name;
|
|
std::string process_manager_name;
|
|
std::string process_protocol_name;
|
|
std::string process_local_cfgm_name;
|
|
std::string process_firewall_name;
|
|
|
|
std::string user_md5;
|
|
std::string group_md5;
|
|
std::string config_manager_md5;
|
|
std::string auto_start_md5;
|
|
|
|
int nos_report_port;
|
|
int msg_time_out;
|
|
int cpu_occupy_max;
|
|
int mem_occupy_max;
|
|
int tcp_socket_max;
|
|
int process_max;
|
|
int cron_max;
|
|
int path_file_max;
|
|
int home_file_max;
|
|
|
|
int process_running_code;
|
|
|
|
int trans_send_port;
|
|
int trans_recv_port;
|
|
};
|