- introduce setting for RPC server address
- restructure RPC server code - stop timer threads when shutting down server git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@187 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
parent
f5e5b1ed34
commit
daeb7b675e
2 changed files with 27 additions and 24 deletions
|
@ -13,6 +13,8 @@ DBSETTINGS = { 'dbhost' : 'localhost',
|
||||||
# courier:jevhi3Wriav
|
# courier:jevhi3Wriav
|
||||||
# gnuviech:SIKKnsyXsV5yU
|
# gnuviech:SIKKnsyXsV5yU
|
||||||
|
|
||||||
|
RPCSERVERADDRESS = ('localhost', 8080)
|
||||||
|
|
||||||
MAIL_SENDER = 'root@gnuviech.info'
|
MAIL_SENDER = 'root@gnuviech.info'
|
||||||
MAIL_RECEIVER = 'root@gnuviech.info'
|
MAIL_RECEIVER = 'root@gnuviech.info'
|
||||||
POPGROUP = 'poponly'
|
POPGROUP = 'poponly'
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
"""
|
||||||
# XML-RPC server for gnuviech-admin tool
|
XML-RPC server for gnuviech-admin tool
|
||||||
# (c) 2006 Jan Dittberner
|
(c) 2006 Jan Dittberner
|
||||||
# $Id$
|
$Id$
|
||||||
#
|
"""
|
||||||
from DocXMLRPCServer import DocXMLRPCServer
|
from DocXMLRPCServer import DocXMLRPCServer
|
||||||
from GnuviechAdmin import ServiceFacade
|
from GnuviechAdmin import ServiceFacade, Settings
|
||||||
import logging
|
import logging, threading
|
||||||
|
|
||||||
def startRPCServer():
|
logger = logging.getLogger()
|
||||||
address = ('localhost', 8080)
|
hdlr = logging.FileHandler('xmlrpcserver.log')
|
||||||
server = DocXMLRPCServer(address)
|
f = logging.Formatter('%(asctime)s %(levelname)s %(module)s: %(message)s')
|
||||||
|
hdlr.setFormatter(f)
|
||||||
|
logger.addHandler(hdlr)
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
server = DocXMLRPCServer(Settings.RPCSERVERADDRESS)
|
||||||
server.register_introspection_functions()
|
server.register_introspection_functions()
|
||||||
server.register_instance(ServiceFacade())
|
server.register_instance(ServiceFacade())
|
||||||
|
|
||||||
|
@ -19,11 +24,7 @@ def startRPCServer():
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
server.server_close()
|
server.server_close()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
for thread in [t for t in threading.enumerate() if t.isAlive() \
|
||||||
logger = logging.getLogger()
|
and isinstance(t, threading._Timer)]:
|
||||||
hdlr = logging.FileHandler('xmlrpcserver.log')
|
logger.debug("Stopping timer thread %s" % thread.getName())
|
||||||
f = logging.Formatter('%(asctime)s %(levelname)s %(module)s: %(message)s')
|
thread.cancel()
|
||||||
hdlr.setFormatter(f)
|
|
||||||
logger.addHandler(hdlr)
|
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
startRPCServer()
|
|
||||||
|
|
Loading…
Reference in a new issue