2014-11-19 00:25:21 +08:00
|
|
|
|
// master_trigger.cpp : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨Ӧ<CCA8>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ㡣
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#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:
|
|
|
|
|
// <20><><EFBFBD>ി<EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䵽ʱ<E4B5BD><CAB1><EFBFBD>ô˺<C3B4><CBBA><EFBFBD>
|
|
|
|
|
virtual void on_trigger()
|
|
|
|
|
{
|
|
|
|
|
format("on trigger now\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <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>
|
|
|
|
|
virtual void proc_pre_jail()
|
|
|
|
|
{
|
|
|
|
|
format("proc_pre_jail\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <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>
|
|
|
|
|
virtual void proc_on_init()
|
|
|
|
|
{
|
|
|
|
|
format("proc init\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ô˺<C3B4><CBBA><EFBFBD>
|
|
|
|
|
virtual void proc_on_exit()
|
|
|
|
|
{
|
|
|
|
|
format("proc exit\r\n");
|
|
|
|
|
}
|
|
|
|
|
protected:
|
|
|
|
|
private:
|
|
|
|
|
};
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
master_trigger_test mt;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
if (argc >= 2 && strcmp(argv[1], "alone") == 0)
|
|
|
|
|
{
|
|
|
|
|
format = (void (*)(const char*, ...)) printf;
|
|
|
|
|
mt.run_alone(NULL, 5, 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD>ʽ
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
mt.run_daemon(argc, argv); // acl_master <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|