Commit 8105faa7 authored by Leigh B Stoller's avatar Leigh B Stoller

Wrap the ssl XMLRPC server with daemon_wrapper in case it dies cause of

a database failure.
parent f442e091
...@@ -73,8 +73,16 @@ case "$1" in ...@@ -73,8 +73,16 @@ case "$1" in
if [ -x @prefix@/sbin/sslxmlrpc_server.py ]; then if [ -x @prefix@/sbin/sslxmlrpc_server.py ]; then
echo -n " sslxmlrpc_server" echo -n " sslxmlrpc_server"
if [ -x @prefix@/sbin/daemon_wrapper ]; then
@prefix@/sbin/daemon_wrapper -i 30 \
-l @prefix@/log/sslxmlrpc_server.log \
-p /var/run/sslxmlrpc_server.pid \
@prefix@/sbin/sslxmlrpc_server.py -f
else
@prefix@/sbin/sslxmlrpc_server.py 2>/dev/null @prefix@/sbin/sslxmlrpc_server.py 2>/dev/null
fi fi
fi
# mfrisbeed started with its own script # mfrisbeed started with its own script
......
...@@ -48,6 +48,9 @@ from libdb import * ...@@ -48,6 +48,9 @@ from libdb import *
# When debugging, runs in foreground printing to stdout instead of syslog # When debugging, runs in foreground printing to stdout instead of syslog
debug = 0 debug = 0
# For daemon wrapper, run in foreground mode.
foreground = 0
# The port to listen on. We should get this from configure. # The port to listen on. We should get this from configure.
PORT = 3069 PORT = 3069
...@@ -618,8 +621,8 @@ class MyServer(SocketServer.ForkingTCPServer, SimpleXMLRPCDispatcher): ...@@ -618,8 +621,8 @@ class MyServer(SocketServer.ForkingTCPServer, SimpleXMLRPCDispatcher):
try: try:
# Parse the options, # Parse the options,
opts, req_args = getopt.getopt(sys.argv[1:], opts, req_args = getopt.getopt(sys.argv[1:],
"dhs:p:c:", "dhs:p:c:f",
[ "debug", "help", "server=", "port=", [ "debug", "foreground", "help", "server=", "port=",
"cert=", "cacert=" ]) "cert=", "cacert=" ])
# ... act on them appropriately, and # ... act on them appropriately, and
for opt, val in opts: for opt, val in opts:
...@@ -643,6 +646,9 @@ try: ...@@ -643,6 +646,9 @@ try:
elif opt in ("-d", "--debug"): elif opt in ("-d", "--debug"):
debug = 1 debug = 1
pass pass
elif opt in ("-f", "--foreground"):
foreground = 1
pass
elif opt in ("-c", "--cert"): elif opt in ("-c", "--cert"):
server_cert = val server_cert = val
pass pass
...@@ -668,8 +674,10 @@ if not debug: ...@@ -668,8 +674,10 @@ if not debug:
getattr(syslog, "LOG_" + string.upper(LOGFACIL))) getattr(syslog, "LOG_" + string.upper(LOGFACIL)))
syslog.syslog(syslog.LOG_INFO, "SSL XMLRPC server starting up"); syslog.syslog(syslog.LOG_INFO, "SSL XMLRPC server starting up");
# We use foreground mode from daemon_wrapper.
if not foreground:
# #
# Daemonize. We redirect our output into a log file cause I have no # We redirect our output into a log file cause I have no
# idea what is going to use plain print. # idea what is going to use plain print.
# #
try: try:
...@@ -689,6 +697,7 @@ if not debug: ...@@ -689,6 +697,7 @@ if not debug:
sys.exit(0) sys.exit(0)
pass pass
os.setsid(); os.setsid();
pass
else: else:
print "SSL XMLRPC server starting up" print "SSL XMLRPC server starting up"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment