There are several ways to deploy a service. In this case we are using a stateful web service so we'll want to create a single instance and deploy it at a fixed URL. We are using here the web infrastructure provided by the popular "Twisted" framework. [Note: Twisted does not come with Python, so you will need to first download and install it from twistedmatrix.com. You will need the core library and also the "Twisted Web" server.] In Twisted, you deploy using a configuration file in Python syntax called a "tac" file, which by convention ends in the letters ".tac".
The first step is to modify the server-config.tac file. Look at the "tac" configuration file, adding the code to the beginning of the SetUpResourceTree function.
server-config.tac
########################################################################### # SetUpResourceTree # ########################################################################### def SetUpResourceTree(root): # -- ADD TO BEGINNING OF FUNCTION --< import SimpleMathService root.putChild('ws', Resource()) root.getStaticEntity('ws').putChild('MathService', SimpleMathService.StatefulWebService()) # >-- ADD TO BEGINNING OF FUNCTION -- ... ...
Next edit the configuration file server-config.txt (in the ConfigParser/Windows .INI syntax) to specify the location of the container as well as to configure the security settings. Currently we only need to worry about the Location section, make sure it matches the below.
Next start the container by running the provided shell script start-container.sh.
Congratulations! You've just created and deployed a stateful Web Service! But how do you know it really worked? In the next section, we'll write a simple client to test our new service.