2019-07-28 10:31:56 +08:00
|
|
|
|
#include "lib_acl.h"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include "service_main.h"
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
char *var_cfg_mysql_dbaddr;
|
|
|
|
|
char *var_cfg_mysql_dbuser;
|
|
|
|
|
char *var_cfg_mysql_dbpass;
|
|
|
|
|
char *var_cfg_mysql_dbname;
|
|
|
|
|
|
|
|
|
|
int var_cfg_mysql_dbmax;
|
|
|
|
|
int var_cfg_mysql_dbping;
|
|
|
|
|
int var_cfg_mysql_dbtimeout;
|
|
|
|
|
int var_cfg_mysql_auto_commit;
|
|
|
|
|
|
|
|
|
|
int var_cfg_debug_mem;
|
|
|
|
|
|
|
|
|
|
/* configure info */
|
|
|
|
|
|
|
|
|
|
/* TODO: you can add configure items here */
|
|
|
|
|
|
|
|
|
|
ACL_CONFIG_BOOL_TABLE service_conf_bool_tab[] = {
|
|
|
|
|
/* TODO: you can add configure variables of int type here */
|
|
|
|
|
{ "debug_mem", 0, &var_cfg_debug_mem },
|
|
|
|
|
{ 0, 0, 0 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ACL_CONFIG_INT_TABLE service_conf_int_tab[] = {
|
|
|
|
|
/* TODO: you can add configure variables of int type here */
|
|
|
|
|
{ "mysql_dbmax", 250, &var_cfg_mysql_dbmax, 0, 0 },
|
|
|
|
|
{ "mysql_dbping", 60, &var_cfg_mysql_dbping, 0, 0 },
|
|
|
|
|
{ "mysql_dbtimeout", 300, &var_cfg_mysql_dbtimeout, 0, 0 },
|
|
|
|
|
{ "mysql_auto_commit", 1, &var_cfg_mysql_auto_commit, 0, 0 },
|
|
|
|
|
|
|
|
|
|
{ 0, 0, 0, 0, 0 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ACL_CONFIG_STR_TABLE service_conf_str_tab[] = {
|
|
|
|
|
|
|
|
|
|
/* TODO: you can add configure variables of (char *) type here */
|
|
|
|
|
{ "mysql_dbaddr", "127.0.0.1:3306", &var_cfg_mysql_dbaddr },
|
|
|
|
|
{ "mysql_dbname", "dbname", &var_cfg_mysql_dbname },
|
|
|
|
|
{ "mysql_dbuser", "dbuser", &var_cfg_mysql_dbuser },
|
|
|
|
|
{ "mysql_dbpass", "111111", &var_cfg_mysql_dbpass },
|
|
|
|
|
|
|
|
|
|
{ 0, 0, 0 },
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
void service_init(void *init_ctx acl_unused)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
const char *ptr = getenv("MASTER_ENV");
|
|
|
|
|
|
|
|
|
|
if (ptr)
|
|
|
|
|
acl_msg_info("env=%s", ptr);
|
|
|
|
|
else
|
|
|
|
|
acl_msg_info("no env");
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void service_exit(void *arg acl_unused)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* Э<>鴦<EFBFBD><E9B4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2017-07-05 00:01:22 +08:00
|
|
|
|
int service_main(void *run_ctx acl_unused, ACL_VSTREAM *client)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
|
|
|
|
char buf[256];
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
ACL_VSTREAM_SET_RWTIMO(client, 1200);
|
|
|
|
|
|
|
|
|
|
if (var_cfg_debug_mem)
|
|
|
|
|
acl_msg_info("total alloc: %d", acl_mempool_total_allocated());
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
if (isatty(ACL_VSTREAM_SOCK(client))) {
|
|
|
|
|
printf("Please input: ");
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
} else
|
|
|
|
|
acl_msg_info("waiting ......");
|
|
|
|
|
ret = acl_vstream_gets(client, buf, sizeof(buf));
|
|
|
|
|
if (ret == ACL_VSTREAM_EOF)
|
|
|
|
|
return (-1);
|
|
|
|
|
buf[ret] = 0;
|
|
|
|
|
if (isatty(ACL_VSTREAM_SOCK(client)))
|
|
|
|
|
ret = acl_vstream_printf("Your input: %s", buf);
|
|
|
|
|
else {
|
|
|
|
|
acl_msg_info("wakeup now, ret=%d", ret);
|
|
|
|
|
ret = acl_vstream_writen(client, buf, strlen(buf));
|
|
|
|
|
}
|
|
|
|
|
if (ret == ACL_VSTREAM_EOF)
|
|
|
|
|
return (-1);
|
|
|
|
|
} while (1);
|
|
|
|
|
|
|
|
|
|
acl_msg_info("over now\r\n");
|
|
|
|
|
return (-1);
|
|
|
|
|
}
|