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 ...@@ -73,7 +73,15 @@ 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"
@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 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,27 +674,30 @@ if not debug: ...@@ -668,27 +674,30 @@ 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.
# Daemonize. We redirect our output into a log file cause I have no if not foreground:
# idea what is going to use plain print. #
# # We redirect our output into a log file cause I have no
try: # idea what is going to use plain print.
fp = open("@prefix@/log/sslxmlrpc_server.log", "a"); #
sys.stdout = fp try:
sys.stderr = fp fp = open("@prefix@/log/sslxmlrpc_server.log", "a");
sys.stdin.close(); sys.stdout = fp
pass sys.stderr = fp
except: sys.stdin.close();
print "Could not open log file for append" pass
sys.exit(1); except:
pass print "Could not open log file for append"
sys.exit(1);
pid = os.fork() pass
if pid:
os.system("echo " + str(pid) + " > /var/run/sslxmlrpc_server.pid") pid = os.fork()
sys.exit(0) if pid:
os.system("echo " + str(pid) + " > /var/run/sslxmlrpc_server.pid")
sys.exit(0)
pass
os.setsid();
pass pass
os.setsid();
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