17 #ifndef HH_SENF_Utils_Daemon_Daemon_ 18 #define HH_SENF_Utils_Daemon_Daemon_ 1 133 void pidFile(std::string
const &);
151 char const **
argv();
154 static void exit(
unsigned code=0);
201 bool pidfileCreate();
202 void installSighandlers();
208 std::string stdoutLog_;
209 std::string stderrLog_;
212 std::string pidfile_;
213 bool pidfileCreated_;
214 bool catchExceptions_;
217 static Daemon * instance_;
227 # define SENF_DAEMON_MAIN(klass) \ 228 int main(int argc, char const ** argv) \ 231 return instance.start(argc, argv); \ void detach()
Detach into background now.
void daemonize(bool)
Configure whether to run in fore- or background.
virtual void configure()
Called before forking to configure the daemon class.
char const ** argv()
Access command line parameters.
virtual void run()
Called to execute main application.
#define SENF_LOG_CLASS_AREA()
StdStream
Select standard stream to redirect.
static void exit(unsigned code=0)
Terminate daemon with failure.
void catchExceptions(bool flag)
void pidFile(std::string const &)
Configure pid file.
void consoleLog(std::string const &, StdStream which=Both)
Configure console log file.
int start(int argc, char const **argv)
Called from main() to launch daemon.
static Daemon & instance()
Return the Daemon instance.
int argc()
Access command line parameter count.
virtual void init()
Called to initialize the main application.
bool daemon()
true, if running as daemon
void logReopen()
Reopen the log files.
void removeDaemonArgs()
Remove the daemon arguments from argc()/argv()
virtual void main()
Called after forking to execute the main application.