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,7 +73,15 @@ case "$1" in
if [ -x @prefix@/sbin/sslxmlrpc_server.py ]; then
echo -n " sslxmlrpc_server"
@prefix@/sbin/sslxmlrpc_server.py 2>/dev/null
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
fi
fi
# mfrisbeed started with its own script
......
......@@ -48,6 +48,9 @@ from libdb import *
# When debugging, runs in foreground printing to stdout instead of syslog
debug = 0
# For daemon wrapper, run in foreground mode.
foreground = 0
# The port to listen on. We should get this from configure.
PORT = 3069
......@@ -618,8 +621,8 @@ class MyServer(SocketServer.ForkingTCPServer, SimpleXMLRPCDispatcher):
try:
# Parse the options,
opts, req_args = getopt.getopt(sys.argv[1:],
"dhs:p:c:",
[ "debug", "help", "server=", "port=",
"dhs:p:c:f",
[ "debug", "foreground", "help", "server=", "port=",
"cert=", "cacert=" ])
# ... act on them appropriately, and
for opt, val in opts:
......@@ -643,6 +646,9 @@ try:
elif opt in ("-d", "--debug"):
debug = 1
pass
elif opt in ("-f", "--foreground"):
foreground = 1
pass
elif opt in ("-c", "--cert"):
server_cert = val
pass
......@@ -668,27 +674,30 @@ if not debug:
getattr(syslog, "LOG_" + string.upper(LOGFACIL)))
syslog.syslog(syslog.LOG_INFO, "SSL XMLRPC server starting up");
#
# Daemonize. We redirect our output into a log file cause I have no
# idea what is going to use plain print.
#
try:
fp = open("@prefix@/log/sslxmlrpc_server.log", "a");
sys.stdout = fp
sys.stderr = fp
sys.stdin.close();
pass
except:
print "Could not open log file for append"
sys.exit(1);
pass
pid = os.fork()
if pid:
os.system("echo " + str(pid) + " > /var/run/sslxmlrpc_server.pid")
sys.exit(0)
# We use foreground mode from daemon_wrapper.
if not foreground:
#
# We redirect our output into a log file cause I have no
# idea what is going to use plain print.
#
try:
fp = open("@prefix@/log/sslxmlrpc_server.log", "a");
sys.stdout = fp
sys.stderr = fp
sys.stdin.close();
pass
except:
print "Could not open log file for append"
sys.exit(1);
pass
pid = os.fork()
if pid:
os.system("echo " + str(pid) + " > /var/run/sslxmlrpc_server.pid")
sys.exit(0)
pass
os.setsid();
pass
os.setsid();
else:
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