Browse Source

fix Linux Daemon

pull/68/head
root 11 years ago
parent
commit
e674014efc
  1. 4
      Daemon.h
  2. 12
      DaemonLinux.cpp
  3. 3
      Makefile

4
Daemon.h

@ -57,6 +57,10 @@ namespace i2p @@ -57,6 +57,10 @@ namespace i2p
virtual bool start();
virtual bool stop();
private:
std::string pidfile;
int pidFilehandle;
};
#endif
}

12
DaemonLinux.cpp

@ -6,6 +6,10 @@ @@ -6,6 +6,10 @@
#include <stdlib.h>
#include <unistd.h>
//#include <boost/filesystem.hpp>
#include "util.h"
void handle_signal(int sig)
{
switch (sig)
@ -26,7 +30,7 @@ void handle_signal(int sig) @@ -26,7 +30,7 @@ void handle_signal(int sig)
case SIGABRT:
case SIGTERM:
case SIGINT:
running = 0; // Exit loop
Daemon.running = 0; // Exit loop
break;
}
}
@ -63,9 +67,9 @@ namespace i2p @@ -63,9 +67,9 @@ namespace i2p
}
// Pidfile
std::string pidfile = i2p::util::filesystem::GetDataDir().string();
pidfile = i2p::util::filesystem::GetDataDir().string();
pidfile.append("/i2pd.pid");
int pidFilehandle = open(pidfile.c_str(), O_RDWR | O_CREAT, 0600);
pidFilehandle = open(pidfile.c_str(), O_RDWR | O_CREAT, 0600);
if (pidFilehandle == -1)
{
LogPrint("Error, could not create pid file (", pidfile, ")\nIs an instance already running?");
@ -90,7 +94,7 @@ namespace i2p @@ -90,7 +94,7 @@ namespace i2p
sigaction(SIGTERM, &sa, 0);
sigaction(SIGINT, &sa, 0);
retunrn Daemon_Singleton::start();
return Daemon_Singleton::start();
}
bool DaemonLinux::stop()

3
Makefile

@ -5,7 +5,8 @@ OBJECTS = obj/i2p.o obj/base64.o obj/NTCPSession.o obj/RouterInfo.o obj/Transpor @@ -5,7 +5,8 @@ OBJECTS = obj/i2p.o obj/base64.o obj/NTCPSession.o obj/RouterInfo.o obj/Transpor
obj/RouterContext.o obj/NetDb.o obj/LeaseSet.o obj/Tunnel.o obj/TunnelEndpoint.o \
obj/TunnelGateway.o obj/TransitTunnel.o obj/I2NPProtocol.o obj/Log.o obj/Garlic.o \
obj/HTTPServer.o obj/Streaming.o obj/Identity.o obj/SSU.o obj/util.o obj/Reseed.o \
obj/UPnP.o obj/TunnelPool.o obj/HTTPProxy.o obj/AddressBook.o
obj/UPnP.o obj/TunnelPool.o obj/HTTPProxy.o obj/AddressBook.o \
obj/Daemon.o obj/DaemonLinux.o
INCFLAGS =
LDFLAGS = -Wl,-rpath,/usr/local/lib -lcryptopp -lboost_system -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
LIBS =

Loading…
Cancel
Save