2017-09-22 12:27:21 +08:00
|
|
|
|
#pragma once
|
2018-01-10 17:48:45 +08:00
|
|
|
|
#include "fiber_cpp_define.hpp"
|
2017-09-22 12:27:21 +08:00
|
|
|
|
//#include "acl_cpp/master/master_base.hpp"
|
|
|
|
|
|
|
|
|
|
struct ACL_VSTREAM;
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
class socket_stream;
|
|
|
|
|
|
|
|
|
|
/**
|
2018-01-06 23:18:40 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD>̷<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2017-09-22 12:27:21 +08:00
|
|
|
|
*/
|
2018-01-10 17:48:45 +08:00
|
|
|
|
class FIBER_CPP_API master_fiber : public master_base
|
2017-09-22 12:27:21 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
2018-01-06 23:18:40 +08:00
|
|
|
|
* <EFBFBD><EFBFBD> acl_master <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param argc {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @param argv {char**} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2017-09-22 12:27:21 +08:00
|
|
|
|
*/
|
|
|
|
|
void run_daemon(int argc, char** argv);
|
|
|
|
|
|
|
|
|
|
/**
|
2018-01-06 23:18:40 +08:00
|
|
|
|
* <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param addrs {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>
|
2017-09-22 12:27:21 +08:00
|
|
|
|
* ip:port, ip:port, ...
|
2018-01-06 23:18:40 +08:00
|
|
|
|
* @param path {const char*} <EFBFBD><EFBFBD> NULL ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
|
2017-09-22 12:27:21 +08:00
|
|
|
|
*/
|
|
|
|
|
bool run_alone(const char* addrs, const char* path = NULL);
|
|
|
|
|
|
|
|
|
|
/**
|
2018-01-06 23:18:40 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ NULL <EFBFBD><EFBFBD>ʾû<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
2017-09-22 12:27:21 +08:00
|
|
|
|
*/
|
|
|
|
|
const char* get_conf_path(void) const;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
master_fiber();
|
|
|
|
|
|
|
|
|
|
virtual ~master_fiber();
|
|
|
|
|
|
|
|
|
|
/**
|
2018-01-06 23:18:40 +08:00
|
|
|
|
* <EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD>̷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param stream {socket_stream&} <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>رո<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
2017-09-22 12:27:21 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual void on_accept(socket_stream& stream) = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
2018-01-06 23:18:40 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>̳߳<EFBFBD>ʼ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>鷽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2017-09-22 12:27:21 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual void thread_on_init(void) {}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static void service_on_listen(void*, ACL_VSTREAM*);
|
|
|
|
|
static void service_on_accept(void*, ACL_VSTREAM*);
|
|
|
|
|
static void service_pre_jail(void*);
|
|
|
|
|
static void service_init(void*);
|
|
|
|
|
static void thread_init(void*);
|
|
|
|
|
static void service_exit(void*);
|
|
|
|
|
static int service_on_sighup(void*, ACL_VSTRING*);
|
|
|
|
|
|
|
|
|
|
void run(int argc, char** argv);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|