r9615 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r9614‎ | r9615 | r9616 >
Date:07:29, 24 June 2005
Author:kateturner
Status:old
Tags:
Comment:
split into two parts: exec and sm-monitor. smm restarts the exec if it dies.
Modified paths:
  • /trunk/servmon/Makefile (modified) (history)
  • /trunk/servmon/monitor.c (added) (history)

Diff [purge]

Index: trunk/servmon/Makefile
@@ -9,9 +9,9 @@
1010 SYSTATDOBJS= systatd.o
1111 SMLOGMSGOBJS= smlogmsg.o
1212
13 -all: servmon smlogmsg systatd
 13+all: exec smlogmsg systatd sm-monitor
1414
15 -servmon: $(SERVMONOBJS) bconf/ldflags
 15+exec: $(SERVMONOBJS) bconf/ldflags
1616 $(CXX) $(CXXFLAGS) $(SERVMONOBJS) -o $@ $(LDFLAGS) -lboost_thread$(BOOST) \
1717 -lboost_regex$(BOOST) -lnetsnmp -lmysqlclient -lssl -lcrypto \
1818 `cat bconf/ldflags`
@@ -27,7 +27,17 @@
2828 $(CC) $(CPPFLAGS) $(CFLAGS) smlogmsg.c -o smlogmsg $(LDFLAGS) `cat bconf/ldflags`
2929 systatd: systatd.c
3030 $(CC) $(CPPFLAGS) $(CFLAGS) systatd.c -o systatd $(LDFLAGS) `cat bconf/ldflags`
 31+sm-monitor: monitor.c
 32+ $(CC) $(CPPFLAGS) $(CFLAGS) monitor.c -o sm-monitor $(LDFLAGS)
3133
 34+install:
 35+ mkdir -p $(PREFIX)/bin
 36+ mkdir -p $(PREFIX)/sbin
 37+ mkdir -p $(PREFIX)/lib/servmon
 38+ cp systatd sm-monitor $(PREFIX)/sbin
 39+ cp smlogmsg $(PREFIX)/bin
 40+ cp exec $(PREFIX)/lib/servmon
 41+
3242 .c.o:
3343 $(CC) $(CPPFLAGS) $(CXXFLAGS) -c $<
3444 .cxx.o:
Index: trunk/servmon/monitor.c
@@ -0,0 +1,40 @@
 2+/* $Header$ */
 3+
 4+#include <stdio.h>
 5+#include <unistd.h>
 6+
 7+#include "bconf/prelude.h"
 8+
 9+#define SERVMON PFX "/lib/servmon/exec"
 10+
 11+int
 12+main(argc, argv)
 13+ int argc;
 14+ char *argv[];
 15+{
 16+ for (;;) {
 17+ pid_t pid;
 18+ int status;
 19+ int lo, hi;
 20+
 21+ if ((pid = fork()) == -1) {
 22+ perror("fork");
 23+ exit(1);
 24+ }
 25+
 26+ if (pid == 0) {
 27+ execv(SERVMON, argv);
 28+ perror("exec");
 29+ exit(1);
 30+ }
 31+
 32+ waitpid(pid, &status, 0);
 33+ lo = status & 0xF;
 34+ hi = status << 8 & 0xF;
 35+ if (lo == 0) {
 36+ fprintf(stderr, "exec exited with exit status %d\n", hi);
 37+ } else {
 38+ fprintf(stderr, "exec exited with signal %d\n", lo);
 39+ }
 40+ }
 41+}
Property changes on: trunk/servmon/monitor.c
___________________________________________________________________
Added: svn:eol-style
142 + native
Added: svn:keywords
243 + Author Date Id Revision

Status & tagging log