-
Notifications
You must be signed in to change notification settings - Fork 18
boot.q
The supplied boot.q
script in the root of the repository provides a simple way to start a kdb+ process and initialise the kdb-common framework. It is optional, and require.q
can still be loaded and initialised manually.
NOTE: boot.q
should be referenced with an absolute path so require.q
continues to work even if the process working directory is changed at a later point (e.g. with system "l"
).
Running q $(pwd)/boot.q
will perform the following:
- Loads
require.q
- Loads the following libraries
log
cargs
- Parses all command line arguments into
.boot.args
This environment variable can be set to customise the root folder that require.q
will be initialised from for library search for an application built with kdb-common
.
NOTE: It is assumed that kdb-common
exists as a folder at the top level of this folder.
Example:
> tree /tmp/my-application/
/tmp/my-application/
├── kdb-common -> /home/jas/git/kdb-common
└── src
└── myLib.q
> export KDB_APPLICATION_ROOT=/tmp/my-application
> rlwrap $QHOME/l64/q /tmp/my-application/kdb-common/boot.q
...
Application root: /tmp/my-application | kdb-common root: /tmp/my-application/kdb-common
...
q) .require.lib`myLib
2021.11.05 15:26:32.723 INFO pid-3264 jas 0 Loading library: myLib
2021.11.05 15:26:32.723 INFO pid-3264 jas 0 Loading /tmp/my-application/src/myLib.q
This command line argument can be specified to load additional libraries during initialisation. Multiple libraries can be specified by comma-separating them.
Example:
> cd ~/git/kdb-common
> rlrwap $QHOME/l64/q $(pwd)/boot.q --load-libs compress,rand
...
Application root: /home/jas/git/kdb-common | kdb-common root: /home/jas/git/kdb-common
...
q) select from .require.loadedLibs where lib in `compress`rand
lib | loaded loadedTime inited initedTime files
--------| ------------------------------------------------------------------------------------------------------------------
compress| 1 2021.11.05D15:28:55.892364000 1 2021.11.05D15:28:55.892389000 :/home/jas/git/kdb-common/src/compress.q
rand | 1 2021.11.05D15:28:55.892665000 0 :/home/jas/git/kdb-common/src/rand.q
This command line argument can be specified to load a specific q file (not via 'require'), optionally execute a function specified with --script-func
and then automatically exit the process.
Enables the following features:
- Error trap mode 1 (
\e 1
) - Stops the process exiting when running with
--script
A process started with boot.q
will have the following objects available for use:
-
.boot.args
: A dictionary of command line arguments, including kdb+ arguments- See
.cargs.getWithInternal
- See
-
.boot.root.kdbCommon
: The root path where the kdb-common files reside- Based on the path of
boot.q
via.z.f
- Based on the path of
-
.boot.root.app
: The root path whererequire.q
has been initialised from for library search- This will only be different from
.boot.root.kdbCommon
if$KDB_APPLICATION_ROOT
has been set
- This will only be different from
Copyright (C) Sport Trades Ltd 2017 - 2020, John Keys and Jaskirat Rajasansir 2020 - 2024