diff options
| author | ced <> | 2007-02-03 22:58:57 +0000 |
|---|---|---|
| committer | ced <> | 2007-02-03 22:58:57 +0000 |
| commit | 840953821b0bbc4c2e753b3515d87a906fedd64f (patch) | |
| tree | c13094daced7767531e439d6962ff14c862f33a9 /bin/tinyerp-server.py | |
| parent | cd498105b9dd5d2a93a3aa0075d06c31ab5f10d5 (diff) | |
CLIENT-SERVER: improve netrpc
bzr revid: ced-228717f183c1bf3b42dbe1e9df452bde0fb3645c
Diffstat (limited to 'bin/tinyerp-server.py')
| -rwxr-xr-x | bin/tinyerp-server.py | 79 |
1 files changed, 47 insertions, 32 deletions
diff --git a/bin/tinyerp-server.py b/bin/tinyerp-server.py index 70518098b5d..da0397b1657 100755 --- a/bin/tinyerp-server.py +++ b/bin/tinyerp-server.py @@ -66,10 +66,10 @@ logger = netsvc.Logger() # import the tools module so that the commandline parameters are parsed #----------------------------------------------------------------------- import tools +import time if sys.platform=='win32': import mx.DateTime - import time mx.DateTime.strptime = lambda x,y: mx.DateTime.mktime(time.strptime(x, y)) #os.chdir(tools.file_path_root) @@ -200,35 +200,44 @@ if tools.config["stop_after_init"]: #---------------------------------------------------------- # Launch Server #---------------------------------------------------------- -try: - port = int(tools.config["port"]) -except Exception: - logger.notifyChannel("init", netsvc.LOG_ERROR, "invalid port '%s'!" % (tools.config["port"],)) - sys.exit(1) -interface = tools.config["interface"] -secure = tools.config["secure"] - -httpd = netsvc.HttpDaemon(interface,port, secure) - -if tools.config["xmlrpc"]: - xml_gw = netsvc.xmlrpc.RpcGateway('web-services') - httpd.attach("/xmlrpc", xml_gw ) - logger.notifyChannel("web-services", netsvc.LOG_INFO, "starting XML-RPC services, port "+str(port)) - -# -#if tools.config["soap"]: -# soap_gw = netsvc.xmlrpc.RpcGateway('web-services') -# httpd.attach("/soap", soap_gw ) -# logger.notifyChannel("web-services", netsvc.LOG_INFO, 'starting SOAP services, port '+str(port)) -# -if not (netsvc.HAS_SSL and tools.config['secure']): - logger.notifyChannel("web-services", netsvc.LOG_INFO, "You are not using the SSL layer") -else: - logger.notifyChannel("web-services", netsvc.LOG_INFO, "You are using the SSL Layer") - -tinySocket = netsvc.TinySocketServerThread(interface, 8085, False) -logger.notifyChannel("web-services", netsvc.LOG_INFO, "starting TinySocket service, port "+str(8085)) +if tools.config['xmlrpc']: + try: + port = int(tools.config["port"]) + except Exception: + logger.notifyChannel("init", netsvc.LOG_ERROR, "invalid port '%s'!" % (tools.config["port"],)) + sys.exit(1) + interface = tools.config["interface"] + secure = tools.config["secure"] + + httpd = netsvc.HttpDaemon(interface,port, secure) + + if tools.config["xmlrpc"]: + xml_gw = netsvc.xmlrpc.RpcGateway('web-services') + httpd.attach("/xmlrpc", xml_gw ) + logger.notifyChannel("web-services", netsvc.LOG_INFO, "starting XML-RPC services, port "+str(port)) + + # + #if tools.config["soap"]: + # soap_gw = netsvc.xmlrpc.RpcGateway('web-services') + # httpd.attach("/soap", soap_gw ) + # logger.notifyChannel("web-services", netsvc.LOG_INFO, 'starting SOAP services, port '+str(port)) + # + if not (netsvc.HAS_SSL and tools.config['secure']): + logger.notifyChannel("web-services", netsvc.LOG_INFO, "You are not using the SSL layer") + else: + logger.notifyChannel("web-services", netsvc.LOG_INFO, "You are using the SSL Layer") + +if tools.config['netrpc']: + try: + netport = int(tools.config["netport"]) + except Exception: + logger.notifyChannel("init", netsvc.LOG_ERROR, "invalid port '%s'!" % (tools.config["netport"],)) + sys.exit(1) + netinterface = tools.config["netinterface"] + + tinySocket = netsvc.TinySocketServerThread(netinterface, netport, False) + logger.notifyChannel("web-services", netsvc.LOG_INFO, "starting netrpc service, port "+str(netport)) def handler(signum, frame): from tools import config @@ -245,10 +254,16 @@ if config['pidfile']: pidtext="%d" % (os.getpid()) fd.write(pidtext) fd.close() + signal.signal(signal.SIGINT, handler) signal.signal(signal.SIGTERM, handler) logger.notifyChannel("web-services", netsvc.LOG_INFO, 'the server is running, waiting for connections...') -tinySocket.start() -httpd.start() -dispatcher.run() +if tools.config['netrpc']: + tinySocket.start() +if tools.config['xmlrpc']: + httpd.start() +#dispatcher.run() + +while True: + time.sleep(1) |
