2019-07-28 10:31:56 +08:00
|
|
|
|
// master_trigger.cpp : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨Ӧ<CCA8>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ㡣
|
2014-11-19 00:25:21 +08:00
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "acl_cpp/lib_acl.hpp"
|
|
|
|
|
|
|
|
|
|
static char *var_cfg_debug_msg;
|
|
|
|
|
|
|
|
|
|
static acl::master_str_tbl var_conf_str_tab[] = {
|
|
|
|
|
{ "debug_msg", "test_msg", &var_cfg_debug_msg },
|
|
|
|
|
|
|
|
|
|
{ 0, 0, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int var_cfg_debug_enable;
|
|
|
|
|
|
|
|
|
|
static acl::master_bool_tbl var_conf_bool_tab[] = {
|
|
|
|
|
{ "debug_enable", 1, &var_cfg_debug_enable },
|
|
|
|
|
|
|
|
|
|
{ 0, 0, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int var_cfg_io_timeout;
|
|
|
|
|
|
|
|
|
|
static acl::master_int_tbl var_conf_int_tab[] = {
|
|
|
|
|
{ "io_timeout", 120, &var_cfg_io_timeout, 0, 0 },
|
|
|
|
|
|
|
|
|
|
{ 0, 0 , 0 , 0, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void (*format)(const char*, ...) = acl::log::msg1;
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
using namespace acl;
|
|
|
|
|
|
|
|
|
|
class master_trigger_test : public master_trigger
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
master_trigger_test() {}
|
|
|
|
|
~master_trigger_test() {}
|
|
|
|
|
|
|
|
|
|
protected:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD>ി<EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䵽ʱ<E4B5BD><CAB1><EFBFBD>ô˺<C3B4><CBBA><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
virtual void on_trigger()
|
|
|
|
|
{
|
|
|
|
|
format("on trigger now\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ô˺<C3B4><CBBA><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
virtual void proc_pre_jail()
|
|
|
|
|
{
|
|
|
|
|
format("proc_pre_jail\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD><EFBFBD>ô˺<C3B4><CBBA><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
virtual void proc_on_init()
|
|
|
|
|
{
|
|
|
|
|
format("proc init\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ô˺<C3B4><CBBA><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
virtual void proc_on_exit()
|
|
|
|
|
{
|
|
|
|
|
format("proc exit\r\n");
|
|
|
|
|
}
|
|
|
|
|
protected:
|
|
|
|
|
private:
|
|
|
|
|
};
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
master_trigger_test mt;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
mt.set_cfg_int(var_conf_int_tab);
|
|
|
|
|
mt.set_cfg_int64(NULL);
|
|
|
|
|
mt.set_cfg_str(var_conf_str_tab);
|
|
|
|
|
mt.set_cfg_bool(var_conf_bool_tab);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2021-01-17 18:57:37 +08:00
|
|
|
|
if (argc == 1 || (argc >= 2 && strcmp(argv[1], "alone") == 0))
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
2019-07-28 10:31:56 +08:00
|
|
|
|
mt.run_alone(NULL, 5, 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD>ʽ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
2015-02-11 09:28:05 +08:00
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
2019-07-28 10:31:56 +08:00
|
|
|
|
mt.run_alone(NULL, 5, 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD>ʽ
|
2015-02-11 09:28:05 +08:00
|
|
|
|
#else
|
2019-07-28 10:31:56 +08:00
|
|
|
|
mt.run_daemon(argc, argv); // acl_master <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
2015-02-11 09:28:05 +08:00
|
|
|
|
#endif
|
|
|
|
|
}
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|