One of the nice things added in Zato 2.0 is the improved ability to store code of one's API services directly in a server's hot-deploy directory - each time a file is saved it is uploaded on server and automatically propagated throughout all the other nodes in a cluster the given server belongs to.
Now, this in itself had been already doable since the very 1.0 version but the newest release added means to configure servers not to clean up hot-deploy directory after the code was picked up - meaning anything that is saved in there stays until it's deleted manually.
Two cool things can be achieved thanks to it:
- Working in deploy-on-save mode
- Deploying code from a repository checkout
To make it all possible, navigate to all of the servers' server.conf files, find hot_deploy.delete_after_pick_up, change it from True to False and restart all servers. This is the only time they will be restarted, promise.
Working in deploy-on-save mode
- Let's say your server is in /home/user/zato/server1
- Save your files in /home/user/zato/server1/pickup-dir now
- Each time it's saved, note in server.log how it's picked up and deployed
- This lets you make use of the service in the actual environment a moment after it's saved
Deploying code from a repository checkout
- Essentially, this is deploy-on-save described above working on a grander scale
- Instead of saving individual files, everything that is needed for a given solution is stored in the hot-deploy's pickup directory in one go
- Can be easily plugged into Jenkins or other automation tools
- You can try it right now using this sample repository prepared for the article
- Go to a server's pickup dir
- Delete anything it already contains
- Issue the command below:
$ git clone https://github.com/zatosource/hot-deploy-sample.git .
- Witness that the two services just checked out are being nicely picked up by all servers in a cluster
- This concludes the deployment - an environment has been just updated with newest versions of services and they are already operational, as can be confirmed in web-admin