mirror of https://github.com/PurpleI2P/i2pd.git
I2P: End-to-End encrypted and anonymous Internet
https://i2pd.website/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
1.9 KiB
108 lines
1.9 KiB
9 years ago
|
#ifndef DAEMON_H__
|
||
|
#define DAEMON_H__
|
||
|
|
||
9 years ago
|
#include <memory>
|
||
11 years ago
|
#include <string>
|
||
11 years ago
|
|
||
|
namespace i2p
|
||
|
{
|
||
|
namespace util
|
||
|
{
|
||
11 years ago
|
class Daemon_Singleton_Private;
|
||
11 years ago
|
class Daemon_Singleton
|
||
|
{
|
||
|
public:
|
||
11 years ago
|
virtual bool init(int argc, char* argv[]);
|
||
11 years ago
|
virtual bool start();
|
||
|
virtual bool stop();
|
||
9 years ago
|
virtual void run () {};
|
||
11 years ago
|
|
||
9 years ago
|
bool isDaemon;
|
||
|
bool running;
|
||
11 years ago
|
|
||
|
protected:
|
||
11 years ago
|
Daemon_Singleton();
|
||
|
virtual ~Daemon_Singleton();
|
||
|
|
||
9 years ago
|
bool IsService () const;
|
||
10 years ago
|
|
||
11 years ago
|
// d-pointer for httpServer, httpProxy, etc.
|
||
|
class Daemon_Singleton_Private;
|
||
|
Daemon_Singleton_Private &d;
|
||
11 years ago
|
};
|
||
|
|
||
9 years ago
|
#if defined(QT_GUI_LIB) // check if QT
|
||
|
#define Daemon i2p::util::DaemonQT::Instance()
|
||
9 years ago
|
// dummy, invoked from RunQT
|
||
9 years ago
|
class DaemonQT: public i2p::util::Daemon_Singleton
|
||
9 years ago
|
{
|
||
|
public:
|
||
|
|
||
|
static DaemonQT& Instance()
|
||
|
{
|
||
|
static DaemonQT instance;
|
||
|
return instance;
|
||
|
}
|
||
9 years ago
|
};
|
||
9 years ago
|
|
||
8 years ago
|
#elif defined(ANDROID)
|
||
|
#define Daemon i2p::util::DaemonAndroid::Instance()
|
||
|
// dummy, invoked from android/jni/DaemonAndroid.*
|
||
|
class DaemonAndroid: public i2p::util::Daemon_Singleton
|
||
|
{
|
||
|
public:
|
||
|
|
||
|
static DaemonAndroid& Instance()
|
||
|
{
|
||
|
static DaemonAndroid instance;
|
||
|
return instance;
|
||
|
}
|
||
|
};
|
||
|
|
||
9 years ago
|
#elif defined(_WIN32)
|
||
|
#define Daemon i2p::util::DaemonWin32::Instance()
|
||
11 years ago
|
class DaemonWin32 : public Daemon_Singleton
|
||
|
{
|
||
|
public:
|
||
|
static DaemonWin32& Instance()
|
||
|
{
|
||
|
static DaemonWin32 instance;
|
||
|
return instance;
|
||
|
}
|
||
|
|
||
9 years ago
|
bool init(int argc, char* argv[]);
|
||
|
bool start();
|
||
9 years ago
|
bool stop();
|
||
9 years ago
|
void run ();
|
||
11 years ago
|
};
|
||
|
#else
|
||
9 years ago
|
#define Daemon i2p::util::DaemonLinux::Instance()
|
||
9 years ago
|
class DaemonLinux : public Daemon_Singleton
|
||
11 years ago
|
{
|
||
9 years ago
|
public:
|
||
|
static DaemonLinux& Instance()
|
||
|
{
|
||
|
static DaemonLinux instance;
|
||
|
return instance;
|
||
|
}
|
||
11 years ago
|
|
||
9 years ago
|
bool start();
|
||
|
bool stop();
|
||
|
void run ();
|
||
|
|
||
|
private:
|
||
|
|
||
|
std::string pidfile;
|
||
|
int pidFH;
|
||
|
|
||
|
public:
|
||
9 years ago
|
|
||
8 years ago
|
int gracefulShutdownInterval; // in seconds
|
||
11 years ago
|
|
||
11 years ago
|
};
|
||
|
#endif
|
||
|
}
|
||
11 years ago
|
}
|
||
9 years ago
|
|
||
|
#endif // DAEMON_H__
|