i2pd/Daemon.h

79 lines
1.3 KiB
C
Raw Normal View History

#ifndef DAEMON_H__
#define DAEMON_H__
2014-04-24 17:10:46 +02:00
#include <string>
2014-04-20 03:54:34 +02:00
#ifdef _WIN32
#define Daemon i2p::util::DaemonWin32::Instance()
#else
#define Daemon i2p::util::DaemonLinux::Instance()
#endif
2014-04-20 03:54:34 +02:00
namespace i2p
{
namespace util
{
class Daemon_Singleton_Private;
2014-04-20 03:54:34 +02:00
class Daemon_Singleton
{
public:
virtual bool init(int argc, char* argv[]);
2014-04-20 03:54:34 +02:00
virtual bool start();
virtual bool stop();
2016-03-08 21:02:32 +01:00
virtual void run () {};
2014-04-20 03:54:34 +02:00
bool isLogging;
bool isDaemon;
2014-04-20 03:54:34 +02:00
bool running;
2014-04-20 03:54:34 +02:00
protected:
Daemon_Singleton();
virtual ~Daemon_Singleton();
2014-10-17 15:55:41 +02:00
bool IsService () const;
// d-pointer for httpServer, httpProxy, etc.
class Daemon_Singleton_Private;
Daemon_Singleton_Private &d;
2014-04-20 03:54:34 +02:00
};
#ifdef _WIN32
class DaemonWin32 : public Daemon_Singleton
{
public:
static DaemonWin32& Instance()
{
static DaemonWin32 instance;
return instance;
}
virtual bool init(int argc, char* argv[]);
2014-04-20 03:54:34 +02:00
virtual bool start();
virtual bool stop();
};
#else
class DaemonLinux : public Daemon_Singleton
{
public:
static DaemonLinux& Instance()
{
static DaemonLinux instance;
return instance;
}
2016-03-08 21:02:32 +01:00
bool start();
bool stop();
; void run ();
2014-04-22 06:15:07 +02:00
private:
std::string pidfile;
2016-01-11 11:58:39 +01:00
int pidFH;
2014-04-22 06:15:07 +02:00
2014-04-20 03:54:34 +02:00
};
#endif
}
2014-04-22 06:15:07 +02:00
}
#endif // DAEMON_H__