Deployable services

When you build applications with the ValueA framework, it’s often desirable to split different applications in their own directory structure. The ValueA service packages help to prepare for production and package all requirements into a single distributable file.

valuea_pkg

The valuea_pkg tool is the management tool to build and install service package and comes as part of the valuea_framework. To check if it’s correctly installed, you should be able to execute the following command from your project directory:

valuea_pkg --help

Prepare for build

To prepare for a package build, you should make sure your project directory contains a json type file named package.json, which holds the metadata for this package including it’s (unique) name and optional version.

package.json
1{
2  "name": "valuea_docsamples",
3  "version": "0.0.1",
4  "pip" : {
5      "packages": [
6          "ValueAframework>=1.0.9"
7      ]
8  }
9}

The sample above contains only the basics, when a name is not provided the tool tries to figure on out automatically, when a version is not specified an attempt will be made to query your git repository.

Note

The pip section contains python package dependencies which will be automatically installed after deployment, if you’re packages are not available in the standard PyPI library you can specify an additional url to download them from when installing.

Build a package

Building a package is pretty straightforward (technically it contains two steps), from your project directory execute the following command:

valuea_pkg . --action build

Which will create a new package in the dist/ directory of your project, containing it’s name and version in the filename. Our sample package will look like this valuea_docsamples-0.0.1.vap.

Note

You might see changes in your source files, the build command first makes sure the package can live within the same service and model directories by extending it’s path using pkgutil (the prepare call). It’s usually safe to commit these changes to your source repository.

Installing packages

The easiest way to install a service package is to go to the directory where your services are started (which contains the config and message broker). While there execute the following command to install our “valuea_docsamples” service.

./valuea_pkg.py /path/to/valuea_docsamples-0.0.1.vap --action install

Note

By default our service broker doesn’t expose your newly installed packages, you need to make sure they are registered in your broker.conf. Please add service_paths=packages/* to the queue section which will listen for these service calls.

Using an additional PyPI source

Private pip installable packages, such as our framework, are not available in the public PyPI package repository. However you can make use of an external source in addition to the standard repository, to do so you can add the option --pip-extra-index-url.

This expects a http[s] reachable location, using the following directory structure for our framework package:

.
|-- archive
|   |-- valueaframework
|       |-- ValueAframework-1.0.10-py2-none-any.whl

You can use python to serve these files for testing purposes.

cd archive
python -m SimpleHTTPServer 9000

A full install command using our local hosted framework would look like this:

./valuea_pkg.py /path/to/valuea_docsamples-0.0.1.vap --action install  --pip-extra-index-url http://127.0.0.1:9000/