mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
41 lines
982 B
C++
41 lines
982 B
C++
#ifndef HUSKY_DAEMON_H_
|
|
#define HUSKY_DAEMON_H_
|
|
#include "globals.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <sys/wait.h>
|
|
#include <sys/stat.h>
|
|
#include <signal.h>
|
|
#include <logger.hpp>
|
|
#include "ServerFrame.h"
|
|
|
|
namespace Husky
|
|
{
|
|
using namespace Limonp;
|
|
|
|
class Daemon
|
|
{
|
|
public:
|
|
Daemon(IRequestHandler * pHandler)
|
|
{
|
|
m_pHandler = pHandler;
|
|
}
|
|
~Daemon(){};
|
|
public:
|
|
bool Start(unsigned int port, unsigned int threadNum);
|
|
bool Stop();
|
|
public:
|
|
static void initAsDaemon();
|
|
static void sigMasterHandler(int sig);
|
|
static void sigChildHandler(int sig);
|
|
static bool isAbnormalExit(int pid, int status);
|
|
private:
|
|
static IRequestHandler* m_pHandler;
|
|
static ServerFrame m_ServerFrame;
|
|
static int m_nChildPid;
|
|
};
|
|
}
|
|
#endif
|