Install QPacker and work through some examples of using it to build applications
cd ~/KxCloudEdition/code/ sh qpacker-install.sh
The installer will also prompt for an installation directory.
user@instance:~/KxCloudEdition/code$ sh qpacker-install-1.0.0.sh Installation Directory [default /home/user] Installed.
Set your Git username and email:
git config --global user.name "John Smith" git config --global user.email "firstname.lastname@example.org"
This completes the successful installation and configuration of QPacker.
Combine q and C code
qp.json file you can see that the entry point of the application that is being built is the
hello.q script, which has a dependency on
clib dependency has been included as a subfolder of the application, which has its own
qp.json file defining its entrypoint and dependencies.
The share object library is built from the underlying
Inspect the chained build dependencies as defined in the
- Link functions in
- Create an application that loads the
cliblibrary and executes the entry point
hello.q, which contains a call to the hello C function.
qp build to build the project. You will see something like
user@instance:~/KxCloudEdition/examples/qpacker/cloud-c-sample$ qp build INFO | Build | Starting build for application [default] INFO | Build | Dependency [so] INFO | Main | (18646-4) Finished. INFO | Build | Dependency [clib] INFO | Build | Docker build --build-arg base=alpine:3.9.6 -f /home/user/KxCloudEdition/examples/qpacker/cloud-c-sample/qpbuild/dep/so/Dockerfile.alpine -t sobuilder /home/user/KxCloudEdition/examples/qpacker/cloud-c-sample/qpbuild/dep/so INFO | Build | docker run --rm -v /home/user/KxCloudEdition/examples/qpacker/cloud-c-sample/clib:/opt/qpacker/ -v /home/user/KxCloudEdition/examples/qpacker/cloud-c-sample:/opt/qpbuildroot -v /home/user/KxCloudEdition/examples/qpacker/cloud-c-sample/qpbuild/dep/so:/opt/so/ -w /opt/qpacker -e CFLAGS=-I/opt/so/kx-c-lib/c/c sobuilder qpmake clib libhello.so INFO | Build | Creating clib.0.20210226.75658.qpk INFO | Main | (18612-3) Finished. INFO | Build | Dependency [q] INFO | Main | (19011-3) Finished. INFO | Build | App [default] INFO | Build | [docker build -t qlocker /home/user/KxCloudEdition/examples/qpacker/cloud-c-sample/qpbuild/dep/q] INFO | Build | Building with docker... INFO | Build | [docker run --env-file /tmp/qp.19047.env.list --rm -v /home/user/KxCloudEdition/examples/qpacker/cloud-c-sample:/opt/kx/data -v /tmp/qp.19047.qpignore:/opt/kx/qpconfig/.qpignore -v /home/user/.qp.licenses:/opt/kx/lic-out -w /opt/kx/data qlocker] INFO | Build | Write loaders for locked q files INFO | Build | Creating cloud-c-sample.0.20210226.75662.qpk INFO | Build | Creating Dockerfile [Dockerfile.default] INFO | Build | [docker build -f Dockerfile.default .] INFO | Main | (18582-2) Finished.
Notice that the application has been packaged as an artifact called
cloud-c-sample.qpk in the
qpbuild/qpk/ folder which can be used in other projects.
Next step is to run the application by executing
qp run. A call has been executed print a
hello message via the clib library.
INFO | Run | Target [default] INFO | Run | docker run --rm --env-file /home/user/KxCloudEdition/examples/qpacker/cloud-c-sample/qpbuild/.env -v /home/user/.config/gcloud/:/root/.config/gcloud:ro -it 4bdafcfbde8e98b5f8d431fc3217a90f10f67e7a1756b86ce0c42d3408d83a5d INFO: Get kdb+ license from KDB_LICENSE_B64 environment variable INFO: testing and installing kc.lic INFO: successful RUN [q startq.q ] KDB+ 4.0 Cloud Edition 2021.03.12 Copyright (C) 1993-2021 Kx Systems l64/ 2()core 3735MB root 3b3147e22fc8 172.17.0.2 EXPIRE 2022.02.23 email@example.com KXCE #???????? hello from q test hello from C! INFO | Main | (20510-2) Finished.
Reset the project with
Build and execute an application with a dependency on embedPy
qp.json file shows an application:
- The entrypoint is
hello.q: dependency on q is implied by the
- A dependency on embedPy is explicitly stated with the
Build the project using
It builds a Docker image with the necessary dependencies.
Run the application with
qp run default.
Basic tick system¶
An application that consists of a feed, a tickerplant, a realtime database, a historical database and a gateway
The entrypoint for each of the processes can be seen in
README.md describes the contents of the package.
qp build to build the images, following instructions in the README file.
In this example we see how easy it is to configure and run a multiprocess system using QPacker.
make use of the
QPPATH environment variable for future examples in the quickstart guide
QPPATH items are separated by colon
: on Linux and macOS, but by semicolon
; on Windows.
See extra details in qp.json documentation