Skip to content

Commit

Permalink
Logging agent: print debugging information on SIGINFO
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Aug 27, 2010
1 parent f3f4fe4 commit 96b9c6b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ext/common/LoggingAgent/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ using namespace Passenger;


static struct ev_loop *eventLoop;
static LoggingServer *loggingServer;

static struct ev_loop *
createEventLoop() {
Expand Down Expand Up @@ -120,6 +121,12 @@ caughtExitSignal(ev::sig &watcher, int revents) {
ev_unloop(eventLoop, EVUNLOOP_ONE);
}

void
printInfo(ev::sig &watcher, int revents) {
loggingServer->dump(cout);
cout.flush();
}

static string
myself() {
struct passwd *entry = getpwuid(geteuid());
Expand Down Expand Up @@ -238,11 +245,13 @@ main(int argc, char *argv[]) {
unionStationServiceAddress,
unionStationServicePort,
unionStationServiceCert);
loggingServer = &server;


ev::io feedbackFdWatcher(eventLoop);
ev::sig sigintWatcher(eventLoop);
ev::sig sigtermWatcher(eventLoop);
ev::sig siginfoWatcher(eventLoop);

if (feedbackFdAvailable()) {
MessageChannel feedbackChannel(FEEDBACK_FD);
Expand All @@ -254,6 +263,8 @@ main(int argc, char *argv[]) {
sigintWatcher.start(SIGINT);
sigtermWatcher.set<&caughtExitSignal>();
sigtermWatcher.start(SIGTERM);
siginfoWatcher.set<&printInfo>();
siginfoWatcher.start(SIGINFO);


/********** Initialized! Enter main loop... **********/
Expand Down

0 comments on commit 96b9c6b

Please sign in to comment.