2014-04-20 05:54:34 +04:00
|
|
|
#pragma once
|
2014-04-24 19:10:46 +04:00
|
|
|
#include <string>
|
2014-04-20 05:54:34 +04:00
|
|
|
|
2014-04-23 02:07:21 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define Daemon i2p::util::DaemonWin32::Instance()
|
|
|
|
#else
|
|
|
|
#define Daemon i2p::util::DaemonLinux::Instance()
|
|
|
|
#endif
|
2014-04-20 05:54:34 +04:00
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
2014-04-23 02:07:21 +04:00
|
|
|
class Daemon_Singleton_Private;
|
2014-04-20 05:54:34 +04:00
|
|
|
class Daemon_Singleton
|
|
|
|
{
|
|
|
|
public:
|
2014-04-23 02:07:21 +04:00
|
|
|
virtual bool init(int argc, char* argv[]);
|
2014-04-20 05:54:34 +04:00
|
|
|
virtual bool start();
|
|
|
|
virtual bool stop();
|
|
|
|
|
|
|
|
int isLogging;
|
|
|
|
int isDaemon;
|
|
|
|
|
2014-04-22 09:13:35 +04:00
|
|
|
int running;
|
2014-04-20 05:54:34 +04:00
|
|
|
|
|
|
|
protected:
|
2014-04-23 02:07:21 +04:00
|
|
|
Daemon_Singleton();
|
|
|
|
virtual ~Daemon_Singleton();
|
|
|
|
|
2014-10-17 17:55:41 +04:00
|
|
|
bool IsService () const;
|
|
|
|
|
2014-04-23 02:07:21 +04:00
|
|
|
// d-pointer for httpServer, httpProxy, etc.
|
|
|
|
class Daemon_Singleton_Private;
|
|
|
|
Daemon_Singleton_Private &d;
|
2014-04-20 05:54:34 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
class DaemonWin32 : public Daemon_Singleton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static DaemonWin32& Instance()
|
|
|
|
{
|
|
|
|
static DaemonWin32 instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2014-04-23 02:07:21 +04:00
|
|
|
virtual bool init(int argc, char* argv[]);
|
2014-04-20 05:54:34 +04:00
|
|
|
virtual bool start();
|
|
|
|
virtual bool stop();
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
class DaemonLinux : public Daemon_Singleton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static DaemonLinux& Instance()
|
|
|
|
{
|
|
|
|
static DaemonLinux instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool start();
|
|
|
|
virtual bool stop();
|
2014-04-22 08:15:07 +04:00
|
|
|
private:
|
|
|
|
std::string pidfile;
|
|
|
|
int pidFilehandle;
|
|
|
|
|
2014-04-20 05:54:34 +04:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
}
|
2014-04-22 08:15:07 +04:00
|
|
|
}
|