Blog
Each Zato environment ships with default configuration that lets its servers be started from a Visual Studio Code's debugger
Servers started in this way can run remotely, e.g. your local IDE may be on Mac or Windows while your Zato servers will be in a remote Linux instance. This will still let you debug your services deployed remotely.
It does not matter whether the server is under Docker or if it runs in a Linux VM directly
This article contains step-by-step instructions on how to start a Zato server in such a manner and how to debug your code remotely from VS Code
Ensure that your remote Zato server runs in a Linux system that has at least 2 CPUs and 2 GB of RAM. If you use AWS, a medium instance will be the correct one to choose.
Make sure that there is SSH connectivity between your localhost and the remote Linux server, that is, you can ssh into the system where the Zato server is. As a reminder, if you use Docker Quickstart, the default port is 22022.
If the server runs in a Docker Quickstart instance, there are no further prerequisites and you can skip to the next section
If you created a Zato cluster yourself, check if these two files exist:
If the files do not exist, download them here: launch.json and settings.json
Once downloaded, save them to the locations above; if the .vscode
directory does not exist, create it. The end result should be that if, for instance, your environment is in /opt/zato/env/dev
, the files will go to /opt/zato/env/dev/.vscode
.
In VS Code, install an extension called Remote - SSH
After you install it, there will be a new button available in the bottom-left hand side corner of your IDE. The button will let you open SSH connections. Click it and then click "Connect to Host"
/opt/zato/env/qs-1/
. In other environments, navigate to your environment's path accordingly.Run and Debug
icon:Remote Zato Main
option:The IDE will work now on installing all of its own components in the remote Linux server - that may take a couple of minutes the first time around. The process is CPU-intensive which is why 2 CPUs are a prerequisite.
If VS Code tells you that its Python IDE extension is not installed in the remote SSH system, choose to install it over SSH. This may also take a couple of minutes.
Allow for some time until the IDE completes the installation of its remote components - there will be feedback provided in the IDE window's footer. Once they are installed, proceed to the next section below.
demo.py
and hot-deploy it in the now-already-started remote server. Note the highlighted line, we are going to add a breakpoint to it soon.# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class MyService(Service):
def handle(self):
msg = 'Hello, I am a demo service'
self.logger.info(msg)
/path/to/server/work/hot-deploy/current/demo.py
and open it:Invoke the service in any way you prefer, e.g. through REST, Dashboard or from command line
The debugger will stop at line 9, showing the local variables, the call stack and other details, exactly as if it was a local server
Congratulations! This concludes the process, everything is set up, you can debug your Zato API services remotely now.