i2pd/Daemon.h

97 lines
1.6 KiB
C
Raw Normal View History

#ifndef DAEMON_H__
#define DAEMON_H__
2014-04-24 15:10:46 +00:00
#include <string>
2014-04-20 01:54:34 +00:00
namespace i2p
{
namespace util
{
class Daemon_Singleton_Private;
2014-04-20 01:54:34 +00:00
class Daemon_Singleton
{
public:
virtual bool init(int argc, char* argv[]);
2014-04-20 01:54:34 +00:00
virtual bool start();
virtual bool stop();
2016-03-08 20:02:32 +00:00
virtual void run () {};
2014-04-20 01:54:34 +00:00
bool isDaemon;
bool running;
2014-04-20 01:54:34 +00:00
protected:
Daemon_Singleton();
virtual ~Daemon_Singleton();
2016-03-09 19:41:14 +00:00
bool IsService () const;
2014-10-17 13:55:41 +00:00
// d-pointer for httpServer, httpProxy, etc.
class Daemon_Singleton_Private;
Daemon_Singleton_Private &d;
2014-04-20 01:54:34 +00:00
};
#if defined(QT_GUI_LIB) // check if QT
#define Daemon i2p::util::DaemonQT::Instance()
class DaemonQT: public i2p::util::Daemon_Singleton
{
public:
static DaemonQT& Instance()
{
static DaemonQT instance;
return instance;
}
2016-06-15 16:20:31 +00:00
bool init(int argc, char* argv[]);
bool start();
bool stop();
void run ();
};
#elif defined(_WIN32)
#define Daemon i2p::util::DaemonWin32::Instance()
2014-04-20 01:54:34 +00:00
class DaemonWin32 : public Daemon_Singleton
{
public:
static DaemonWin32& Instance()
{
static DaemonWin32 instance;
return instance;
}
2016-03-09 19:41:14 +00:00
bool init(int argc, char* argv[]);
bool start();
2016-03-29 16:34:53 +00:00
bool stop();
2016-03-09 19:41:14 +00:00
void run ();
2014-04-20 01:54:34 +00:00
};
#else
#define Daemon i2p::util::DaemonLinux::Instance()
2016-06-14 00:52:17 +00:00
class DaemonLinux : public Daemon_Singleton
2014-04-20 01:54:34 +00:00
{
2016-03-29 16:34:53 +00:00
public:
static DaemonLinux& Instance()
{
static DaemonLinux instance;
return instance;
}
2014-04-20 01:54:34 +00:00
2016-03-29 16:34:53 +00:00
bool start();
bool stop();
void run ();
private:
std::string pidfile;
int pidFH;
public:
2016-03-08 20:02:32 +00:00
2016-03-29 16:34:53 +00:00
int gracefullShutdownInterval; // in seconds
2014-04-22 04:15:07 +00:00
2014-04-20 01:54:34 +00:00
};
#endif
}
2014-04-22 04:15:07 +00:00
}
#endif // DAEMON_H__