Hot-deployment

Overview

  • Make sure you understand the difference between hot-deployment and static deployment.
  • Keep in mind that configuration and services that are hot-deployed become persistent, i.e. once deployed, they will be available after a server is restarted and there is no need to deploy them after each restart
  • If needed, it is possible to switch between hot-deployment and static deployment or to mix the two

Deploying configuration

  • Configuration is always deployed using zato enmasse
  • Refer to a dedicated chapter that goes into the details of how enmasse can be used for automation

Services - default configuration

  • Each server comes with a default hot-deployment directory that the server monitors for changes
  • Any Python module with services or data models placed in the directory will be automatically picked up by the server and deployed to all servers in the cluster, including the server that picks up the code
  • The default path to the pickup directory is /path/to/server/pickup/incoming/services/
  • To deploy code, simply copy it to that directory and the server will trigger the hot-deployment process all across the cluster
$ cp /path/to/code/*.py /path/to/server/pickup/incoming/services/

Services - custom pickup directories

  • It is possible to add user-defined pickup directories that will act exactly as the default one described above
  • To add a pickup directory, open file /path/to/server/config/repo/pickup.conf and add an entry such as the one below (a restart is needed after you add it):

    [hot-deploy.user.my.python.code]
    pickup_from=/my/custom/directory/
    
  • Note that the name of the entry must start with hot-deploy.user. - what follows this prefix acts as a description and it is up to you but what the description is but this specific prefix is required

$ cp /path/to/code/*.py /my/custom/directory/

Or, if the Python code has been already previously deployed:

$ touch /my/custom/directory/*.py

Services - deploying from a git clone

  • This technique is an extension of the above ones
  • First, create a git clone of the repository with your code
  • Next, configure a user-defined pickup directory using pickup.conf as in the previous example and make it point to a directory in the clone that contains the code
  • Then, simply use git pull in the pickup directory any time there is a need to deploy code
  • The end effect will be that a server will pick up and deploy all the changes that git pull brought in to the repository
$ cd /my/git/clone/src/services
$ git pull

Services - IDE

  • Services and other code can be hot-deployed directly from your IDE each time Ctrl-S / Cmd-S is pressed
  • Consult the details for your IDE: Visual Studio Code and PyCharm

Services - deploying from Dashboard

  • Services and other code can be hot-deployed directly from Dashboard (e.g. at http://localhost:8183)
  • In Dashboard, go to Services -> List services -> Click "Upload services" -> Choose one or more files to upload -> Click OK
  • This will hot-deploy exactly as all the other methods described above