Commits

Anthony Tuininga  committed ba6e831

Added some documentation on how services are run with cx_Freeze.

  • Participants
  • Parent commits 70ba4bd

Comments (0)

Files changed (2)

File samples/service/Config.py

+#------------------------------------------------------------------------------
+# Config.py
+#   This file defines information about the service. The following four
+# attributes are expected to be defined and if they are not an exception will
+# be thrown when attempting to create the service:
+#
+#   NAME
+#       the name to call the service with one %s place holder that will be used
+#       to identify the service further.
+#
+#   DISPLAY_NAME
+#       the value to use as the display name for the service with one %s place
+#       holder that will be used to identify the service further.
+#
+#   MODULE_NAME
+#       the name of the module implementing the service.
+#
+#   CLASS_NAME
+#       the name of the class within the module implementing the service. This
+#       class should accept no parameters in the constructor. It should have a
+#       method called "Initialize" which will accept the configuration file
+#       name. It should also have a method called "Run" which will be called
+#       with no parameters when the service is started. It should also have a
+#       method called "Stop" which will be called with no parameters when the
+#       service is stopped using the service control GUI.
+#------------------------------------------------------------------------------
+
 NAME = "cx_FreezeSampleService%s"
 DISPLAY_NAME = "cx_Freeze Sample Service - %s"
 MODULE_NAME = "ServiceHandler"
 CLASS_NAME = "Handler"
+

File samples/service/ServiceHandler.py

+"""
+Implements a simple service using cx_Freeze.
+
+This sample makes use of cx_PyGenLib (http://cx-pygenlib.sourceforge.net) and
+cx_Logging (http://cx-logging.sourceforge.net).
+"""
+
 import cx_Logging
 import cx_Threads
 import sys
 
 class Handler(object):
 
+    # no parameters are permitted; all configuration should be placed in the
+    # configuration file and handled in the Initialize() method
     def __init__(self):
         cx_Logging.Info("creating handler instance")
         self.stopEvent = cx_Threads.Event()
 
+    # called when the service is starting
     def Initialize(self, configFileName):
         cx_Logging.Info("initializing: config file name is %r", configFileName)
 
+    # called when the service is starting immediately after Initialize()
     def Run(self):
         cx_Logging.Info("running service....")
         self.stopEvent.Wait()
 
+    # called when the service is being stopped by the service manager GUI
     def Stop(self):
         cx_Logging.Info("stopping service...")
         self.stopEvent.Set()