[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8248 - in trunk: gnue-appserver/src gnue-common/src/apps
From: |
btami |
Subject: |
[gnue] r8248 - in trunk: gnue-appserver/src gnue-common/src/apps |
Date: |
Mon, 3 Apr 2006 18:20:13 -0500 (CDT) |
Author: btami
Date: 2006-03-23 08:31:23 -0600 (Thu, 23 Mar 2006)
New Revision: 8248
Modified:
trunk/gnue-appserver/src/geasRpcServer.py
trunk/gnue-common/src/apps/GServerApp.py
Log:
add windows service support to appserver
Modified: trunk/gnue-appserver/src/geasRpcServer.py
===================================================================
--- trunk/gnue-appserver/src/geasRpcServer.py 2006-03-22 12:58:05 UTC (rev
8247)
+++ trunk/gnue-appserver/src/geasRpcServer.py 2006-03-23 14:31:23 UTC (rev
8248)
@@ -40,6 +40,59 @@
from gnue.appserver import geasSessionManager
from gnue.appserver import geasConfiguration
+try:
+ import win32service
+except:
+ geasService = None
+else:
+ import win32event
+ import win32service
+ import servicemanager
+ import win32serviceutil
+
+ class geasService(win32serviceutil.ServiceFramework):
+ _svc_name_ = "GNUe-AppServer"
+ _svc_display_name_ = "GNUe Application Server"
+ _svc_description_ = "GNUe Application Server provides business objects
with arbitary fields and methods"
+
+ def __init__(self, args):
+ win32serviceutil.ServiceFramework.__init__(self, args)
+ self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
+ self.RpcServer = geasRpcServerApp()
+ self.RpcServer.phaseInit()
+
+ def SvcStop(self):
+ self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
+ win32event.SetEvent(self.hWaitStop)
+
+ def SvcDoRun(self):
+ # Write an event log record - in debug mode we will also
+ # see this message printed.
+ servicemanager.LogMsg(
+ servicemanager.EVENTLOG_INFORMATION_TYPE,
+ servicemanager.PYS_SERVICE_STARTED,
+ (self._svc_name_, '')
+ )
+
+ # Create a new SessionManager instance which will be served by the
various
+ # transport adapters
+ service = self.RpcServer.requestSessionManager ()
+ servers = server.bind (self.RpcServer._transports, service)
+
+ # Start the server for the different protocolls
+ for adapter in servers.values ():
+ thread.start_new_thread (adapter.serve, ())
+
+ rc = win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
+ if rc == win32event.WAIT_OBJECT_0:
+ adapter.shutdown ()
+
+ servicemanager.LogMsg(
+ servicemanager.EVENTLOG_INFORMATION_TYPE,
+ servicemanager.PYS_SERVICE_STOPPED,
+ (self._svc_name_, "")
+ )
+
# =============================================================================
# RPC application class
@@ -95,11 +148,15 @@
['loglevel', None, 'loglevel', 1, None, 'loglevel', _(
"""If set to 1, provides information on data dispatched to the RPC
-interface.""")],
+interface.""")],
+
['modulepath', 'm', 'modulepath', True, None, 'pathlist',
- _("Semicolon-separated list of paths to load modules from")]
+ _("Semicolon-separated list of paths to load modules from")],
+
+ ['startup', None, 'startup', 1, None, 'manual|auto|disabled', _(
+"""Special option for windows service install/update command.""")]
]
-
+
# USE_DATABASE_OPTIONS = 1 # Conflicts with the existing username and password
# ---------------------------------------------------------------------------
@@ -158,7 +215,7 @@
if rpctype in ('xmlrpc','xmlrpc.pw_xmlrpc','xmlrpc.py_xmlrpc'):
port = gConfig ("rpcport")
- print u_("Exporting our services via %(rpctype)s (port %(port)s) ...") %
\
+ print _("Exporting our services via %(rpctype)s (port %(port)s) ...") % \
{"rpctype": rpctype, "port": port}
params = {'port': int (port),
'allowed_hosts': gConfig ('allowed_hosts'),
@@ -178,7 +235,7 @@
elif rpctype == "pyro":
port = gConfig ("rpcport")
- print u_("Exporting our services via %(rpctype)s (port %(port)s) ...") %
\
+ print _("Exporting our services via %(rpctype)s (port %(port)s) ...") % \
{"rpctype": rpctype, "port": port}
params = {'port': int (port),
'bindto': gConfig ('bindto'),
@@ -214,6 +271,26 @@
self.selftest ()
return
+ if geasService and self.ARGUMENTS:
+ if self.ARGUMENTS[0] in ["install", "remove", "update", "start", "stop",
"restart"]:
+ if self.OPTIONS ["connection"]:
+ # TODO: more command line option processing
+ # win32serviceutil.HandleCommandLine only accepts
+ # short options in customInstallOptions :(
+ geasService._exe_args_ = '-c ' + self.OPTIONS ["connection"]
+ # This magic function, handles service installation/removal, etc....
+ # Sample command lines:
+ # Installation:
+ # python geasRpcServer.py -c gnue --startup auto install
+ # Removal:
+ # python geasRpcServer.py remove
+ # etc...
+ win32serviceutil.HandleCommandLine(
+ geasService,
+ argv = sys.argv,
+ customInstallOptions = "c:")
+ return
+
# Create a new SessionManager instance which will be served by the various
# transport adapters
service = self.requestSessionManager ()
@@ -301,11 +378,11 @@
'language' : i18n.language})
print _("Step 3: Creating object list ...")
- list = sm.request (session, "address_person", [], ["address_zip"],
+ list = session.request ("address_person", [], ["address_zip"],
["address_name", "address_street", "address_city"])
print _("Step 4: Retrieving first instance ...")
- rset = sm.fetch (session,list,0,1)
+ rset = list.fetch (0,1)
if len (rset):
print o(u_("""
Modified: trunk/gnue-common/src/apps/GServerApp.py
===================================================================
--- trunk/gnue-common/src/apps/GServerApp.py 2006-03-22 12:58:05 UTC (rev
8247)
+++ trunk/gnue-common/src/apps/GServerApp.py 2006-03-23 14:31:23 UTC (rev
8248)
@@ -69,12 +69,16 @@
if os.name == 'posix':
self.__removeStaleFile ()
self.__createPidFile (0)
+
+ try:
+ signal.signal (signal.SIGTERM, self._terminate)
+ except ValueError:
+ # signal only works in main thread, but
+ # in a win32 service we are not in the main thread here
+ pass
- signal.signal (signal.SIGTERM, self._terminate)
-
-
# This can be overwritten by code necessary
# for startup. If overwritten, do not first
# call the original GServerApp.run(self) as
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8248 - in trunk: gnue-appserver/src gnue-common/src/apps,
btami <=