OCT 增加HTTP服务配置项支持
This commit is contained in:
parent
a933d6a44a
commit
1aaad54c7e
|
@ -326,12 +326,8 @@ const char *config_item_dump_fmt(const char *titleMessage) {
|
|||
CFG_BOOL_VALUE(pItem) ? "True" : "False");
|
||||
break;
|
||||
case VALUE_TYPE_INTEGRAL:
|
||||
s = sdscatprintf(s,
|
||||
"|%4d | %-25s | %-45s | %-44lld |\n",
|
||||
pItem->cfgId,
|
||||
tmp2,
|
||||
pItem->pcfgKey,
|
||||
CFG_INT_VALUE(pItem));
|
||||
s = sdscatprintf(
|
||||
s, "|%4d | %-25s | %-45s | %-44lld |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_INT_VALUE(pItem));
|
||||
break;
|
||||
case VALUE_TYPE_FLOAT:
|
||||
s = sdscatprintf(s,
|
||||
|
@ -484,13 +480,17 @@ do {
|
|||
/* 消息队列相配置 */ \
|
||||
/* ZeroMq配置 */ \
|
||||
ADD_CFG_ITEM(CFG_MQ_SVR_PORT, "application.zero_mq.svr_port", VALUE_TYPE_INTEGRAL, "6278", "ZeroMQ server port"); \
|
||||
ADD_CFG_ITEM(CFG_MQ_DATA_PATH, "application.zero_mq.agent_addr", VALUE_TYPE_STRING, "ipc:///tmp/msg_fifo0", "ZeroMQ Agent data path"); \
|
||||
ADD_CFG_ITEM(CFG_MQ_DATA_PATH, "application.zero_mq.agent_addr", VALUE_TYPE_STRING, "ipc:///tmp/msg_fifo0", "ZeroMQ Agent data path"); \
|
||||
/* vxLan 隧道配置 */ \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_NIC_NAME, "application.vxlan_wan.nic", VALUE_TYPE_STRING, "", "Network card name to send data"); \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_SUPPORT, "application.vxlan_wan.enable", VALUE_TYPE_BOOL, "1", "Is support vxLan tune"); \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_PEER_IP, "application.vxlan_wan.peer_ip", VALUE_TYPE_STRING, "", "vxLan peer ip address"); \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_PEER_MAC, "application.vxlan_wan.peer_mac", VALUE_TYPE_STRING, "", "vxLan peer mac address"); \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_PKG_FILTER, "application.vxlan_wan.pkg_filter", VALUE_TYPE_STRING, "", "vxLan package filter"); \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_NIC_NAME, "application.vxlan_wan.nic", VALUE_TYPE_STRING, "", "Network card name to send data"); \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_SUPPORT, "application.vxlan_wan.enable", VALUE_TYPE_BOOL, "1", "Is support vxLan tune"); \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_PEER_IP, "application.vxlan_wan.peer_ip", VALUE_TYPE_STRING, "", "vxLan peer ip address"); \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_PEER_MAC, "application.vxlan_wan.peer_mac", VALUE_TYPE_STRING, "", "vxLan peer mac address"); \
|
||||
ADD_CFG_ITEM(CFG_VXLAN_PKG_FILTER, "application.vxlan_wan.pkg_filter", VALUE_TYPE_STRING, "", "vxLan package filter"); \
|
||||
/*HTTP Server 配置*/ \
|
||||
ADD_CFG_ITEM(CFG_HTTP_SVR_ADDR, "application.http_svr.listen_addr", VALUE_TYPE_STRING, "0.0.0.0", "Network address to listen on"); \
|
||||
ADD_CFG_ITEM(CFG_HTTP_SVR_PORT, "application.http_svr.listen_port", VALUE_TYPE_INTEGRAL, "6789", "Network port to listen on"); \
|
||||
ADD_CFG_ITEM(CFG_HTTP_SVR_TCP_NODELAY, "application.http_svr.tcp_nodelay", VALUE_TYPE_BOOL, "1", "TCP delay switch"); \
|
||||
} while (0)// clang-format on
|
||||
|
||||
int init_config_system(const char *pCfgFile, const char *pKey) {
|
||||
|
|
|
@ -3,6 +3,18 @@
|
|||
//
|
||||
#include "config.h"
|
||||
|
||||
const char* config_get_http_server_addr() {
|
||||
return cfg_get_string_value(CFG_HTTP_SVR_ADDR);
|
||||
}
|
||||
|
||||
unsigned int config_get_http_server_port() {
|
||||
return cfg_get_integral_value(CFG_HTTP_SVR_PORT);
|
||||
}
|
||||
|
||||
int config_get_http_server_tcp_nodelay() {
|
||||
return cfg_get_bool_value(CFG_HTTP_SVR_TCP_NODELAY);
|
||||
}
|
||||
|
||||
const char *config_get_vxlan_nic_name() {
|
||||
return cfg_get_string_value(CFG_VXLAN_NIC_NAME);
|
||||
}
|
||||
|
|
|
@ -19,34 +19,37 @@ typedef enum {
|
|||
} CONFIG_VALUE_TYPE;
|
||||
|
||||
typedef enum {
|
||||
CFG_DIRECTORY = 0,
|
||||
CFG_CURL_CA_PATH = 1,
|
||||
CFG_BANNER_SHOW = 2,
|
||||
CFG_HARDWARE_WATCH = 3,
|
||||
CFG_HARDWARE_REFRESH = 4,
|
||||
CFG_WATCH_CPU = 5,
|
||||
CFG_WATCH_MEMORY = 6,
|
||||
CFG_WATCH_DISK = 7,
|
||||
CFG_WATCH_SENSOR = 8,
|
||||
CFG_CPU_REFRESH = 9,
|
||||
CFG_MEM_REFRESH = 10,
|
||||
CFG_DISK_REFRESH = 11,
|
||||
CFG_SENSOR_REFRESH = 12,
|
||||
CFG_DB_REDIS_SERVER = 13,
|
||||
CFG_DB_REDIS_PORT = 14,
|
||||
CFG_DB_REDIS_PASSWD = 15,
|
||||
CFG_DB_MYSQL_SERVER = 16,
|
||||
CFG_DB_MYSQL_PORT = 17,
|
||||
CFG_DB_MYSQL_USER = 18,
|
||||
CFG_DB_MYSQL_PASSWD = 19,
|
||||
CFG_DB_MYSQL_DB_NAME = 20,
|
||||
CFG_MQ_SVR_PORT = 21,
|
||||
CFG_MQ_DATA_PATH = 22,
|
||||
CFG_VXLAN_NIC_NAME = 23,
|
||||
CFG_VXLAN_SUPPORT = 24,
|
||||
CFG_VXLAN_PEER_IP = 25,
|
||||
CFG_VXLAN_PEER_MAC = 26,
|
||||
CFG_VXLAN_PKG_FILTER = 27,
|
||||
CFG_DIRECTORY = 0,
|
||||
CFG_CURL_CA_PATH = 1,
|
||||
CFG_BANNER_SHOW = 2,
|
||||
CFG_HARDWARE_WATCH = 3,
|
||||
CFG_HARDWARE_REFRESH = 4,
|
||||
CFG_WATCH_CPU = 5,
|
||||
CFG_WATCH_MEMORY = 6,
|
||||
CFG_WATCH_DISK = 7,
|
||||
CFG_WATCH_SENSOR = 8,
|
||||
CFG_CPU_REFRESH = 9,
|
||||
CFG_MEM_REFRESH = 10,
|
||||
CFG_DISK_REFRESH = 11,
|
||||
CFG_SENSOR_REFRESH = 12,
|
||||
CFG_DB_REDIS_SERVER = 13,
|
||||
CFG_DB_REDIS_PORT = 14,
|
||||
CFG_DB_REDIS_PASSWD = 15,
|
||||
CFG_DB_MYSQL_SERVER = 16,
|
||||
CFG_DB_MYSQL_PORT = 17,
|
||||
CFG_DB_MYSQL_USER = 18,
|
||||
CFG_DB_MYSQL_PASSWD = 19,
|
||||
CFG_DB_MYSQL_DB_NAME = 20,
|
||||
CFG_MQ_SVR_PORT = 21,
|
||||
CFG_MQ_DATA_PATH = 22,
|
||||
CFG_VXLAN_NIC_NAME = 23,
|
||||
CFG_VXLAN_SUPPORT = 24,
|
||||
CFG_VXLAN_PEER_IP = 25,
|
||||
CFG_VXLAN_PEER_MAC = 26,
|
||||
CFG_VXLAN_PKG_FILTER = 27,
|
||||
CFG_HTTP_SVR_ADDR = 29,
|
||||
CFG_HTTP_SVR_PORT = 30,
|
||||
CFG_HTTP_SVR_TCP_NODELAY = 31,
|
||||
CONFIG_ITEM_ID_MAX
|
||||
} CONFIG_ITEM_ID;
|
||||
|
||||
|
@ -76,21 +79,23 @@ const char *cfg_get_mysql_database();
|
|||
int cfg_get_zero_mq_port();
|
||||
const char *cfg_get_zero_mq_data_path();
|
||||
|
||||
const char *cfg_get_string_value(CONFIG_ITEM_ID id);
|
||||
long double cfg_get_float_value(CONFIG_ITEM_ID id);
|
||||
int cfg_get_bool_value(CONFIG_ITEM_ID id);
|
||||
long long cfg_get_integral_value(CONFIG_ITEM_ID id);
|
||||
int init_config_system(const char *pCfgFile, const char *pKey);
|
||||
void config_item_dump(const char *titleMessage);
|
||||
const char *config_item_dump_fmt(const char *titleMessage);
|
||||
const char *get_config_key(const char *pKeygen);
|
||||
const char *get_config_keygen();
|
||||
int cfg_get_support_vxlan();
|
||||
const char *config_get_vxlan_nic_name();
|
||||
const char *config_get_vxlan_peer_mac();
|
||||
const char *config_get_vxlan_peer_ip();
|
||||
const char *config_get_vxlan_pkg_filter();
|
||||
|
||||
const char *cfg_get_string_value(CONFIG_ITEM_ID id);
|
||||
long double cfg_get_float_value(CONFIG_ITEM_ID id);
|
||||
int cfg_get_bool_value(CONFIG_ITEM_ID id);
|
||||
long long cfg_get_integral_value(CONFIG_ITEM_ID id);
|
||||
int init_config_system(const char *pCfgFile, const char *pKey);
|
||||
void config_item_dump(const char *titleMessage);
|
||||
const char *config_item_dump_fmt(const char *titleMessage);
|
||||
const char *get_config_key(const char *pKeygen);
|
||||
const char *get_config_keygen();
|
||||
int cfg_get_support_vxlan();
|
||||
const char *config_get_vxlan_nic_name();
|
||||
const char *config_get_vxlan_peer_mac();
|
||||
const char *config_get_vxlan_peer_ip();
|
||||
const char *config_get_vxlan_pkg_filter();
|
||||
const char *config_get_http_server_addr();
|
||||
unsigned int config_get_http_server_port();
|
||||
int config_get_http_server_tcp_nodelay();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -5,15 +5,16 @@
|
|||
#include "user_errno.h"
|
||||
#include "haywire.h"
|
||||
#include "misc.h"
|
||||
#include "config.h"
|
||||
|
||||
int http_svr_init() {
|
||||
configuration config;
|
||||
config.http_listen_address = "0.0.0.0";
|
||||
config.http_listen_port = 8000;
|
||||
config.http_listen_address = (char*)config_get_http_server_addr();
|
||||
config.http_listen_port = config_get_http_server_port();
|
||||
config.thread_count = 0;
|
||||
config.parser = "http_parser";
|
||||
config.balancer = "ipc";
|
||||
config.tcp_nodelay = TRUE;
|
||||
config.tcp_nodelay = config_get_http_server_tcp_nodelay();
|
||||
config.max_request_size = 1048576;
|
||||
|
||||
hw_init_with_config(&config);
|
||||
|
|
Loading…
Reference in New Issue