1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 08:14:15 +00:00

Daemon::run

This commit is contained in:
orignal 2016-03-08 15:02:32 -05:00
parent ebd356c7bd
commit 4b0d587fe1
3 changed files with 15 additions and 9 deletions

View File

@ -20,6 +20,7 @@ namespace i2p
virtual bool init(int argc, char* argv[]); virtual bool init(int argc, char* argv[]);
virtual bool start(); virtual bool start();
virtual bool stop(); virtual bool stop();
virtual void run () {};
bool isLogging; bool isLogging;
bool isDaemon; bool isDaemon;
@ -61,8 +62,10 @@ namespace i2p
return instance; return instance;
} }
virtual bool start(); bool start();
virtual bool stop(); bool stop();
; void run ();
private: private:
std::string pidfile; std::string pidfile;
int pidFH; int pidFH;

View File

@ -4,6 +4,7 @@
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <thread>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -118,6 +119,14 @@ namespace i2p
return Daemon_Singleton::stop(); return Daemon_Singleton::stop();
} }
void DaemonLinux::run ()
{
while (running)
{
std::this_thread::sleep_for (std::chrono::seconds(1));
}
}
} }
} }

View File

@ -1,4 +1,3 @@
#include <thread>
#include <stdlib.h> #include <stdlib.h>
#include "Daemon.h" #include "Daemon.h"
@ -6,12 +5,7 @@ int main( int argc, char* argv[] )
{ {
Daemon.init(argc, argv); Daemon.init(argc, argv);
if (Daemon.start()) if (Daemon.start())
{ Daemon.run ();
while (Daemon.running)
{
std::this_thread::sleep_for (std::chrono::seconds(1));
}
}
Daemon.stop(); Daemon.stop();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }