Testing and debugging node servers

From Universal Devices, Inc. Wiki

Installing a node server for development/testing

Using the process to package and publishing a node server for release aren't really suited for the development, testing, and debugging of node servers. Below are some tips on setting up an environment for developing node servers.

The first step is to become familiar with the Local node server store. Review the publishing documentation as you'll use most of what's there to publish your node server to the Local node server store while you create, test, and debug it. The Local store is local to your instance of PG3(x). Any node server added to it is only accessible to you. Once you are ready to release, you can then make a "copy" of the Local store entry and submit it to the Production or Non-production store.

It is recommended that you start by creating a git repository somewhere. It could be on GitHub, on your desktop machine, on your Polisy or eisy. Once you have a repository, start populating it with the files needed for a node server. The quickest way is to copy the files from another working node server. There are some examples in the UDI UniversalDevicesInc GitHub that you can use as a starting point. There are other 'free' node servers which are also available on GitHub.

Once you have a git repository with the basic of your node server you may submit it to your Local node server store. This is done using the same form you use to submit to the public stores but select Local as the store to submit to.

For the Installation URL you may use a GitHub repository link. The repository must be public or PG3 won't be able to access it. You can also use a local git repository URL, which again must be accessible without authentication by PG3. In both of these cases you will need to either delete/reinstall to test updates PG3 (but not PG3x) also supports a symlink option. Using a URL that starts with SYM:// will tell PG3 to create a symbolic link to the directory specified. This directory could be a local directory on the Polisy's file system or to a directory that has been mounted to the Polisy by Samba or NFS. With this option, PG3 will see the changes you make immediately and a simple restart of the node server will have your latest changes.

Setting up a development environment on Polisy/eisy

You can do node server development directly on the Polisy/eisy. You should have the development packages (see Admin Console) installed.

  1. Log into the Polisy/eisy using the "admin" account.
  2. Create a git repository for your node server (in /home/admin/mynewnodeserver for example).
  3. Add the necessary files and commit them to the repository.
  4. Create a Local store entry with the Installation URL set to "/home/admin/mynewnodeserver"
  5. Go to the Node Server store, select the Local store, select mynewnodeserver and install it.
  6. Test your node server.

To make changes, edit the files, commit the changes to the repository and then re-install the node server.

If you create and maintain your git repository on the Polisy/eisy, it is recommended that you also back this up somewhere else. With git you can create an empty repository somewhere, set that as a remote repository and push all your local changes to the remote repository as a backup. GitHub is a reasonable choice for a remote repository (you can even set the GitHub repository as a private repository so only you can access it).

Setting up a development environment on Windows desktop

Many people like to use a Windows desktop environment to do development. Visual Studio, for example is very popular. It is possible to do node server development this way and many current node server developers do. The set up can be a bit tricky.

You can follow most of the same steps as for a local environment, but instead of editing the files by logging into the Polisy/eisy, you setup file sharing so that the Polisy/isy allows your Windows desktop to mount /home/admin and access the files there. Most people are using Samba for this.

TODO: Add steps to set up Samba

It is also possible to share the directory where the node servers are installed then make changes directly to the installed node server to aid in debugging. This works better with PG3 than with PG3x as PG3x requires some extra steps

Many people like to use a Windows desktop environment to do development. Visual Studio, for example is very popular. It is possible to do node server development this way and many current node server developers do. The set up can be a bit tricky.

You can follow most of the same steps as for a local environment, but instead of editing the files by logging into the Polisy/eisy, you setup file sharing so that the Polisy/isy allows your Windows desktop to mount /home/admin and access the files there. Most people are using Samba for this.

TODO: Add steps to set up Samba

It is also possible to share the directory where the node servers are installed then make changes directly to the installed node server to aid in debugging. This works better with PG3 than with PG3x as PG3x requires some extra steps.

Using Samba to share /var/polyglot/pg3/ns

Add "admin" to the polyglot group sudo pw group mod polyglot -m admin Allow git to commit despite not being owner of the folder

  • git config --global --add safe.directory '*'

After installing node server change permissions so group as read/write access

  • for example, chmod 664 *.py
  • You'll have to do this after each install/re-install