A practical walkthrough of the TorqX proof-of-concept: the Finance Starter Pack (FSP) real-time
capture + query stack, rebuilt from standalone di.* modules via dependency injection, per the
TorQ Modularisation Plan. Audience is assumed familiar with TorQ and the plan document.
Presenter note. Commands assume you are in the
TorqX-POCproject directory. After the one-timesource ./setenv.shin §1,torqx.shis on$PATH. Lines prefixed#>are the expected output to point at.
Contents
- Cold-start install & run
- Directory structure — how it mirrors the FSP
- Logs & the log-rolling feature
- The
QINITentry point (torqx_init.q) - tmux dev mode (
torqx.shattach) - A custom process:
feed.q - Config: TOML support (a new innovation)
- Versioning & dependency checks
- Discovery (
discovery1) - Chained tickerplant (
chainedtp1) - Client tracking
- Tickerplant type: segmented or classic
- Replaying tickerplant logs
TorqX ships as two repos. For the demo, kdbx-modules (the framework and every module it uses) is already installed on the machine; we clone only the app.
<parent>/
├── kdbx-modules/ # the framework + modules: di/torq/bin/torqx.sh, di/torq/bin/torqx_init.q, di/<module>/... (installed)
└── TorqX-POC/ # THE APP we are demoing (we clone this)
The framework checkout is never copied into the project — the app is just config + a little custom code, and points at the installed framework via one env var (§1).
Clone the app:
cd <parent> # the dir containing kdbx-modules/
git clone <url>/TorqX-POC.git
cd TorqX-POCThe single install edit — setenv.sh. Everything about this deployment is derived from the
clone location automatically (TORQXAPPHOME, TORQXAPPCONFIG, TORQXDATAHOME, TORQXSTACKID).
The only thing setenv.sh can't infer is where the framework is installed:
# setenv.sh — the one line an installer sets:
export TORQXHOME="$dirpath/../kdbx-modules" # sibling layout (default). If kdbx-modules is
# installed elsewhere, use its absolute path.
# QPATH then resolves every di.* module from there (plus the KX-shipped modules):
export QPATH="$TORQXHOME:$HOME/.kx/mod"Everything else in setenv.sh is generic (no user/host paths). TORQXDATAHOME is split out from
TORQXAPPHOME (mirroring TorQ's TORQAPPHOME/TORQDATAHOME) so runtime data (hdb, tp-log, wdb
working dir) can live on a separate volume in a real deployment; here they coincide.
Permissions are on, so every connection needs a user. The snippets below connect as the demo's
inter-process user, torqx (password torqxpass, from appconfig/passwords/default.txt and
appconfig/permissions/default.q), read from TORQXCRED. A process uses the most specific of
appconfig/passwords/{default|<parentproctype>|<proctype>|<procname>}.txt for its own connections (§7).
Source it (once, for interactive use) and start the stack:
source ./setenv.sh
export TORQXCRED=torqx:torqxpass
waitq() { until q -q <<<"exit 0=@[hopen;(\`::$1:$TORQXCRED;500);0]" >/dev/null 2>&1; do sleep 0.5; done; } # block until port $1 answers
torqx.sh start discovery1; waitq 5307 # discovery first - every other process finds its peers through it (§9)
torqx.sh start stp1; waitq 5311
torqx.sh start sctp1; waitq 5312 # rdb1 subscribes to the chained segmented tickerplant (§12)
for p in hdb loader1 feed1 rdb1 sortworker1 sortworker2 sort1 wdb1 idb1 housekeeping1; do torqx.sh start $p; done
waitq 5304; torqx.sh start gateway1 # gateway last, once rdb1 answers - it registers its backends at startup
torqx.sh status
#> discovery1 discovery up pid=...
#> tickerplant1 tickerplant down # classic tickerplant; startwithall 0 (§12)
#> chainedtp1 chainedtp down # likewise
#> stp1 segmentedtp up pid=...
#> sctp1 segmentedchainedtp up pid=...
#> hdb hdb up pid=...
#> feed1 feed up pid=...
#> rdb1 rdb up pid=...
#> wdb1 wdb up pid=...
#> sort1 sort up pid=...
#> sortworker1 sortworker up pid=...
#> sortworker2 sortworker up pid=...
#> idb1 idb up pid=...
#> housekeeping1 housekeeping up pid=...
#> gateway1 gateway up pid=...
#> loader1 loader down # one-shot loader; exits after its run hook
#> tickerlogreplay1 tickerlogreplay down # run on demand (§13)Verify with a query, not torqx.sh status. status reports the pid, and a process whose init
aborted stays up. torqx_init.q sets result only once init completes, so ask each process for it:
for p in 5307 5311 5312 5302 5303 5304 5305 5306 5309 5310; do
q -q <<<"h:hopen\`::$p:$TORQXCRED; -1 \"$p \",string @[h;\"result\`procname\";\`INITFAILED]; exit 0"
done
#> 5307 discovery1
#> 5311 stp1 ...A backend that comes up after the gateway (a restarted rdb, say) is not routed to until the gateway re-registers its backends. Refresh it by hand:
q -q <<<'h:hopen`$"::5306:",getenv`TORQXCRED; h(`.gw.reload;`reloadend); exit 0'Shared hosts:
TORQXSTACKIDmust be unique per user.torqx.shkeys both its liveness check and its log paths (/tmp/torqx_<stackid>_<procname>.log) on it, so two people running this repo under the same id see each other's processes as their own —torqx.sh statuslists them,torqx.sh stopwould kill them, and the second to start cannot write its logs. This has already happened onhomer.setenv.shtherefore defaults totorqx-poc-${USER}. Ports are a separate matter:process.csvports are absolute, so a second stack on one host needs its own port block too.
torqx.sh is deliberately thin: it reads process.csv only to enumerate rows and look up a
port; it never resolves identity (that's di.torq's job — §4). Start/stop one or all:
torqx.sh start rdb1 # one process
torqx.sh stop # stop all
torqx.sh restart gateway1Prove the stack is live end to end — query the gateway, which scatters across rdb (today, in-memory) + hdb (history, on-disk) and joins:
q -q <<'EOF'
h:hopen`$"::5306:",getenv`TORQXCRED;
neg[h](`.gw.asyncexec;"select cnt:count i by sym from trade";`rdb`hdb);
show h[];
\\
EOFThe deferred-sync idiom is
neg[h](.gw.asyncexec;query;servertypes); h[]— send async, thenh[]blocks for the joined reply. In a non-interactive heredoc, keep\as the **first token on its own line** (a trailing; \` on a code line is inert and the session will hang).
TorqX-POC/
├── setenv.sh # env (FSP: setenv.sh)
├── deps.toml # declared module versions ← NEW vs FSP (§8)
├── database.q # tickerplant schema (FSP: database.q — same trade/quote schema)
├── appconfig/
│ ├── process.csv # process registry (FSP: appconfig/process.csv)
│ └── settings/ # per-process config (FSP: appconfig/settings/)
│ ├── default.toml default.q # app-wide defaults (FSP: default.q)
│ ├── tickerplant1.toml tickerplant1.q # per-process settings (FSP: tickerplant.q, rdb.q, ...)
│ ├── rdb1.toml rdb1.q wdb1.toml wdb1.q gateway1.toml gateway1.q ...
│ │ # each .toml has a .q twin - keep one (§7)
└── code/
└── processes/
├── feed.q # custom process (FSP: code/tick/feed.q)
└── loader.q # custom process (FSP: code/processes/*)
└── rdb/examplequeries.q # app query code loaded into the rdb (FSP: code/rdb/)
The mapping to the FSP is 1:1 in shape: process.csv + appconfig/settings/<proc> +
code/processes/<custom>.q + code/<proctype>/*.q + database.q + setenv.sh. A TorQ engineer
finds everything where they expect it.
What's deliberately different:
| Aspect | FSP | TorqX-POC |
|---|---|---|
| Framework code | copied into the project (code/) |
zero-copy — points at installed kdbx-modules/ via TORQXHOME |
| Settings format | .q (executable) |
.toml (inert data) or .q — both shipped, keep one (§7) |
| Process behaviour | code/processes/<proctype>.q |
built-ins are di.* modules; only app-specific procs are files |
| Dependencies | implicit | explicit deps.toml, version-checked at startup (§8) |
| Tickerplant | segmented (STP) | segmented (stp1, chained sctp1); classic TP by config (§12) |
| Not yet built | monitor, reporter, filealerter, metrics, DQC/DQE, kill | — (deferred per plan) |
The code/<proctype>/*.q convention is preserved: code/rdb/examplequeries.q (the FSP's example
countbysym/hloc) is auto-loaded into the rdb at startup, at root, exactly as TorQ's
.proc.loadprocesscode does.
End of day uses the FSP's sort processes. wdb1 saves the day and hands it to sort1, which
sorts it with sortworker1 and sortworker2, moves it into the hdb and reloads the hdb, rdb, idb and
gateway. sort1 and the sortworkers run the wdb module too, started with -parentproctype wdb from
process.csv's extras column as in the FSP, so they share wdb1's settings/wdb.toml (savedir,
hdbdir, reload order); di.torq's builtin sort and sortworker settings put them in sort mode.
Default location. torqx.sh launches each process detached (nohup) with stdout/stderr
redirected to $TORQXLOGDIR (default /tmp):
ls /tmp/torqx_${TORQXSTACKID}_*.log
#> /tmp/torqx_torqx-poc-<user>_discovery1.log ... _rdb1.log _gateway1.log
tail -5 /tmp/torqx_${TORQXSTACKID}_gateway1.logLog rolling (di.torq.logroll). An opt-in module (a design delta from the plan, which folded
rolling into eodtime — see the POC status page). A process turns it on with a [logroll] section;
absent/disabled is a silent no-op. Here the hdb opts in:
cat appconfig/settings/hdb.toml
#> connections = []
#>
#> [logroll]
#> enabled = true
#> dir = "logs"Once enabled, the process takes over its own fd 1/2 and writes timestamped, daily-rolled files
under TORQXAPPHOME/logs/, with stable out_<proc>.log / err_<proc>.log symlinks pointing at
the current file (a direct port of TorQ's fileredirect/rolllogauto):
ls -1 logs/
#> out_hdb.log # <- stable symlink to current
#> out_hdb_2026_07_21D00_00_00_025975000.log # <- rolled at midnight
#> out_hdb_2026_07_20D00_00_00_001379000.log
#> err_hdb.log err_hdb_2026_07_21D...log ...
tail -5 logs/out_hdb.logThe redirect takes over from whichever supervisor (bash nohup here, systemd's journal in production) initially owned fd 1/2 — so it works the same in both launch modes.
TorqX has no per-process launcher files (start_<name>.q). One generic entry point,
kdbx-modules/di/torq/bin/torqx_init.q, is loaded on demand via kdb's QINIT and turns a plain q session into a
TorqX process. Show that the TorqX command-line params mean nothing to q on their own:
# WITHOUT QINIT — q ignores -proctype/-procname; it's just a plain q session:
q -proctype hdb -procname hdb -q <<'EOF'
-1 " .z.x : ", .Q.s1 .z.x;
-1 " di.torq loaded? : ", $[`torq in key `; "yes"; "no - plain q session"];
\\
EOF
#> .z.x : ("-proctype";"hdb";"-procname";"hdb")
#> di.torq loaded? : no - plain q sessionThe args just sit unparsed in .z.x. Now set QINIT (the torqx alias in setenv.sh does exactly
this: QINIT=$TORQXHOME/di/torq/bin/torqx_init.q $QCMD) and the same args make the process resolve its
identity, run the config cascade, build the DI deps, and start the process module — dropping you at
a live q) console for that process:
torqx -proctype hdb -procname hdbtmp -p 5599 # explicit identity, spare port (throwaway)
#> ... WARN logroll interactive session (stdin is a TTY) - NOT redirecting the console ...
#> ... INFO hdb mounting hdb from ...
#> torqx: started hdb hdbtmp # <- torqx_init.q's confirmation line
#> q) # <- live console prompt; try: tables[]
# type \\ (then Enter) to quit this throwaway instanceThe throwaway registers with discovery like any hdb, so the gateway adds it as an hdb backend, and
after you quit it the gateway retries it every 10s until discovery1 restarts (§9). Give it its
own procname (hdbtmp), never a live one.
Note (ties to §3). The hdb has
[logroll] enabled=true. When backgrounded (torqx.sh start, §3)di.torq.logrollredirects the console tologs/— correct for a daemon. When run interactively like this,di.torq.logroll's TTY guard detects the terminal and skips the redirect (theWARNline above), so you keep a usable console. (Any non-logroll proctype — gateway, rdb, tickerplant, … — has a normal console in both cases.)
Omitting -proctype/-procname auto-detects identity from process.csv by this session's
listening port — e.g. torqx -p 5304 becomes rdb1 (requires that port to be free, i.e. that
process not already running).
torqx_init.q is ~10 lines: parse .Q.opt .z.x, tq:use\di.torq, tq.init[proctype;procname;overrides]. -proctype/-procnameare both-or-neither (omit both → auto-detect by listening port);-norunskips the optional.run` hook.
For local development, start processes as attachable tmux sessions (a live q) console per
process) instead of background+logfile. Use the --tmux flag or the devstart/devstop/devattach
aliases. One session per process, named <stackid>-<proc>:
torqx.sh stop gateway1 # devstart refuses a process that is already running
torqx.sh devstart gateway1 # == torqx.sh start gateway1 --tmux
#> starting gateway1 (gateway) in tmux session 'torqx-poc-<user>-gateway1'...
#> attach with: torqx.sh attach gateway1 (or: tmux attach -t torqx-poc-<user>-gateway1)
torqx.sh status
#> gateway1 gateway up pid=... (tmux) # <- tagged only when the RUNNING pid is the tmux one
torqx.sh attach gateway1 # drops you at the live q) console
# ... at the q) prompt, run e.g.: select count i by sym from `.gw ... or any diagnostic
# detach without stopping the process: Ctrl-b then dstop/status work identically for tmux- and nohup-started processes (discovery is by the
-torqxstackid/-proctype/-procname command-line signature, not the TTY). A crash stays visible in
the pane (remain-on-exit); output is still tee'd to the usual logfile; stop/devstop cleans up
the session:
torqx.sh devstop gateway1
torqx.sh start gateway1 # back to normal background mode for the rest of the demoSessions are intuitively named, so you can also bypass torqx.sh: tmux attach -t ${TORQXSTACKID}-rdb1.
Built-in proctypes (hdb/tickerplant/rdb/wdb/gateway) are di.* modules. Anything app-specific is a
plain file under code/processes/<proctype>.q, loaded by di.torq via the same
init[config;deps] contract. feed.q is a faithful port of the FSP feed (same data-generation
machinery), adapted to that contract.
sed -n '107,163p' code/processes/feed.qRequirements for a di.torq custom process (point these out in the file):
- Everything under
\d .<proctype>— here\d .feed(line 28). Publishing at a real root namespace, not ause-mangled one. - Required:
.<proctype>.init[config;deps](line 113) — the entry point di.torq calls.configis the merged settings dict (fromfeed1.toml);depsis the DI dict (log/timer/handlers/servers). - Optional:
.<proctype>.run[]— a post-init one-shot hook di.torq calls if present (skippable with-norun).feed.qhas no run hook (it schedules its own timer job ininit);loader.qdoes define one (run:{[] loadall[]; exit 0}), which is how the loader fires its one-shot load and then terminates — it has no listening port and holds an hdb handle open afternotifyhdb, so without the explicitexitq would sit idle forever; hence it correctly reportsdownonce complete.loadallitself has no exit, so it stays re-triggerable by hand in a console.
Where it interfaces with TorqX (the di.torq-forced divergences from the FSP original, all commented in the file):
- Injected log:
logdep::deps\log; logdep[`info][`feed;"..."](lines 114, 162) — not.lg.o`. - Injected timer:
(deps[\timer]`addjob)[`feedpublish;`.feed.feed;();0D00:00:01*period;1h;()!()](line 160) — not.timer.repeat`. - Connections via the injected
di.torq.servers(lines 148–155):svc::deps\servers; (svc`startup)[config];then **(svc`waitfortype)[tpt;timeout;500]** (block until the TP is up — the modular equivalent of.servers.startupdepcycles) and(svc`gethandlebytype)[tpt;`any], wheretptis the first ofconnections`. - Config-driven: the FSP's hard-coded literals (
syms/prices/mode/cond/... andlen/maxn/qpt) are read fromfeed1.toml(lines 117–127), keeping the ported code generic. - Symbol normalisation:
assyms:{[x] $[11h=abs type x;x;\$x]}(line 111) — TOML gives strings,.q` settings give symbols; normalise at point of use so either format works.
Why. The plan kept TorQ's .q settings files. But a .q settings file is executable code —
it can run arbitrary q at load. That's not hypothetical: in the FSP itself,
settings/segmentedchainedtickerplant.q has a live conditional and settings/default.q has a bare
system"c ...". Config that can execute is a footgun for an ops/config boundary. TorqX adds a
di.util.toml parser and makes TOML the documented default: inert data, comment-friendly, maps
cleanly onto the flat/sectioned settings shape. (Chosen over YAML: no native q parser for either,
and TOML's grammar is far more tractable to hand-build correctly.) .q remains fully supported.
The cascade. di.torq.config merges, later tiers overriding earlier, so a more specific name always wins:
builtin/default → app/default → [builtin/<parentproctype> → app/<parentproctype>] → builtin/<proctype> → app/<proctype> → builtin/<procname> → app/<procname> — and for each tier it reads <name>.q, then
<name>.toml, merging the two; .toml wins any key both set.
A parent type. Started with -parentproctype <name>, a process also reads the <name> tier between
default and its own type: settings/<name>.toml, code/<name>/ and passwords/<name>.txt. torqx.sh
passes the flag through to the process. Here housekeeping1 is started with a parent type pptp and takes
its connection user from passwords/pptp.txt:
# 1. give the parent type its own password file (a dummy user, so the effect is visible)
printf 'torqx:pptpdemo\n' > appconfig/passwords/pptp.txt
# 2. start housekeeping1 with the parent type; the process logs the flag it read
torqx.sh stop housekeeping1
torqx.sh start housekeeping1 -parentproctype pptp; waitq 5310
grep parentproctype /tmp/torqx_${TORQXSTACKID}_housekeeping1.log
#> ... [INFO] [init] read in process parameter of parentproctype=pptp
# 3. its connections now use the user from passwords/pptp.txt, not default.txt
q -q <<<"h:hopen \`::5310:$TORQXCRED; -1 string h\".servers.USERPASS\"; exit 0"
#> torqx:pptpdemo
# 4. put it back: without the file and the flag it uses default.txt again
rm appconfig/passwords/pptp.txt
torqx.sh restart housekeeping1; waitq 5310
q -q <<<"h:hopen \`::5310:$TORQXCRED; -1 string h\".servers.USERPASS\"; exit 0"
#> torqx:torqxpassLive: add a setting, restart, see it take effect. feed1.toml drives the feed's publish
cadence; the feed logs it at startup:
grep publishperiod appconfig/settings/feed1.toml
#> publishperiod = 1
grep "publishing every" /tmp/torqx_${TORQXSTACKID}_feed1.log | tail -1
#> ... INFO feed feed initialised (FSP port): 10 syms, maxn=15, qpt=5, publishing every 1s
# change it, restart just the feed, observe the new value flow through the cascade:
sed -i 's/publishperiod = 1/publishperiod = 2/' appconfig/settings/feed1.toml
torqx.sh restart feed1
sleep 2
grep "publishing every" /tmp/torqx_${TORQXSTACKID}_feed1.log | tail -1
#> ... INFO feed feed initialised (FSP port): ... publishing every 2s
# (revert: sed -i 's/publishperiod = 2/publishperiod = 1/' appconfig/settings/feed1.toml)Pick a format: every settings file ships as a .toml and a .q. Each appconfig/settings/<name>.toml
has an equivalent <name>.q beside it. Keep whichever format you prefer and delete the other. While
both are present, .toml wins any key both set, so an edit to the .q has no effect until its
.toml is gone. A .q settings file is flat name:value lines, one per setting, with / comments;
values are ordinary q (symbols, timespans, dicts). Parse a pair and compare:
q -q <<'EOF'
cfg:use`di.torq.config;
-1 "--- .q settings ---"; show cfg.parsefile "appconfig/settings/rdb1.q";
-1 "--- .toml settings ---"; show cfg.parsefile "appconfig/settings/rdb1.toml";
\\
EOF
#> --- .q settings ---
#> tickerplanttypes| `segmentedchainedtp hdbdir| `hdb replaylog| 1b reloadenabled| 1b ...
#> --- .toml settings ---
#> tickerplanttypes| "segmentedchainedtp" hdbdir| "hdb" replaylog| 1b reloadenabled| 1b ...Same keys; the difference is value type. TOML has no symbol or timespan type, so it gives strings
where the .q gives `hdb or 0D00:00:10. Modules normalise at point of use, so the same module
code reads either format.
Every module carries a plain-text VERSION; the app declares the minimum it needs in
deps.toml. (Both are design deltas from the plan, which proposed an eval'd deps.q — the point of
a pre-flight check is that it shouldn't require loading the module, and manifests shouldn't be
executable, same reasoning as §7.)
cat $TORQXHOME/di/torq/proc/rdb/VERSION $TORQXHOME/di/torq/proc/gateway/VERSION
#> 0.4.0
#> 0.2.0
sed -n '5,33p' deps.toml
#> [dependencies]
#> "di.torq" = "0.5.0" "di.torq.proc.rdb" = "0.4.0" "di.torq.proc.gateway" = "0.2.0" ...di.torq.depcheck runs at the very start of di.torq.init (before identity, config, or any module
load), resolves each declared module on QPATH, reads its VERSION, and enforces the minimum —
collecting all failures before reporting. Demonstrate an unsatisfiable dependency:
# bump a dep to a version that doesn't exist yet:
sed -i 's/"di.torq.proc.rdb" = "0.4.0"/"di.torq.proc.rdb" = "0.5.0"/' deps.toml
torqx.sh restart rdb1
torqx.sh status rdb1
#> rdb1 rdb down # <- refused to start
tail -4 /tmp/torqx_${TORQXSTACKID}_rdb1.log
#> torqx: init failed: DEPENDENCY CHECK FAILED (peer version requirements):
#> di.torq.proc.rdb requires minimum version 0.5.0, found 0.4.0
# revert and it starts clean again:
sed -i 's/"di.torq.proc.rdb" = "0.5.0"/"di.torq.proc.rdb" = "0.4.0"/' deps.toml
torqx.sh restart rdb1
torqx.sh status rdb1
#> rdb1 rdb up pid=...The restarted rdb1 comes up after the gateway, so refresh the gateway's backends (§1) before querying it.
(A missing module reports ... requires minimum version X, not found; a missing deps.toml
altogether is a silent no-op — the whole feature is opt-in.)
di.torq.proc.discovery is a one-to-one port of TorQ's discovery service; di.torq.servers 0.4.0
carries the client half (.servers.* at the legacy root names). As in TorQ, every process
registers with discovery and asks it for the proctypes it needs, rather than dialling
process.csv directly. discovery1 itself dials every process.csv row once at startup.
Start order (§1). Discovery, waiting until it answers; the tickerplant; the rest; the gateway last, once rdb1 answers.
The registry — what discovery knows, and which peers it holds a live handle to:
q -q <<'EOF'
h:hopen`$"::5307:",getenv`TORQXCRED;
show h"select procname,proctype,hpup,w from .servers.SERVERS";
\\
EOF
#> procname proctype hpup w
#> discovery1 discovery :homer...:5307
#> tickerplant1 tickerplant :homer...:5300 # <- listed from process.csv, no handle (not started)
#> stp1 segmentedtp :homer...:5311 # <- listed from process.csv, no handle
#> housekeeping1 housekeeping :homer...:5310 # <- likewise
#> sctp1 segmentedchainedtp :homer...:5312 6
#> hdb hdb :homer...:5302 6
#> loader1 loader :homer...:0 # <- one-shot; registered, then exited
#> feed1 rdb1 wdb1 gateway1 idb1 ... # <- each registered itself, live handleThe tickerplants (stp1 here) and housekeeping never register themselves (none calls servers.startup, as
in TorQ); they are listed from discovery's own process.csv sweep, with a live handle only if they
were already up when discovery started. That is enough for peers: discovery hands out every row
whether or not it holds a handle, and the peer dials it itself.
A late process registers itself. Start one that process.csv doesn't know about, with explicit
identity, then re-run the registry query — it appears, and subscribers (the gateway, for hdb)
are told and dial it:
torqx -proctype hdb -procname hdb2 -p 5308
#> ... [conn] registering with discovery servicesKill discovery and restart it. Peers lose their discovery handle but keep their other
connections. On restart discovery dials every process.csv row and tells each to re-register
(.servers.autodiscovery), so they are all back within milliseconds; a process not in
process.csv (hdb2) comes back on its own discoveryretry timer (10s here).
torqx.sh status discovery1 # note the pid
kill <pid>; torqx.sh start discovery1
# re-run the registry query: every w is filled againDemo pace — appconfig/settings/default.toml. The builtin retry periods are TorQ's 5 minutes;
the app sets retry and discoveryretry to 10s. TOML has no timespan type, so they're written
as strings ("0D00:00:10"), which di.torq.servers converts; a number of seconds works too.
discoveryregister/connectionsfromdiscovery are set to true there, and hopentimeout to 200ms
(builtin 2s): a process waiting on a peer dials every dead peer on each poll. discovery1 keeps
TorQ's 0D (no retries) from its builtin settings.
di.torq.proc.chainedtp is TorQ's chained tickerplant as a kdb-x module. It runs in classic mode, so
switch to it first (§12), then start tickerplant1 and chainedtp1 before rdb1, wdb1 and feed1. rdb1 then
takes its data through chainedtp1 and wdb1 straight from the tickerplant, so the two paths sit side by side:
feed1 → tickerplant1 → chainedtp1 → rdb1
└→ wdb1
rdb1.toml sets tickerplanttypes = "chainedtp", wdb1.toml "tickerplant". chainedtp1 finds
tickerplant1 by name through discovery (builtin setting tickerplantname), waiting for it as long
as it takes, then republishes in one-second batches (pubinterval in chainedtp1.toml).
Its own log. chainedtp1.toml sets createlogfile and logdir, so chainedtp1 writes what it
receives to tplog/chainedtp1_<date>, next to tickerplant1's tplog/tp<date>. rdb1 replays it
when it connects:
grep "replaying log file\|rdb\] subscribed" /tmp/torqx_${TORQXSTACKID}_rdb1.log
#> ... [subscribe] replaying log file (0;`:tplog/chainedtp1_2026.10.29)
#> ... [rdb] subscribed, partition date 2026.10.29Counts at each hop. With the feed stopped (torqx.sh stop feed1) the counts settle and agree:
q -q <<'EOF'
q:{[p;x] h:hopen`$(string p),":",getenv`TORQXCRED; r:h x; hclose h; r};
-1 "chainedtp1: ",-3!q[`::5301;".u.icounts"];
-1 "rdb1: ",-3!q[`::5304;"`trade`quote!(count trade;count quote)"];
\\
EOF
#> chainedtp1: `trade`quote!276 918
#> rdb1: `trade`quote!276 918wdb1 holds the same rows, split between memory and the flushed partition under wdb/.
End of day reaches rdb1 through chainedtp1, which rolls to a new log, and wdb1 directly. The wdb hands the day to sort1, which writes the partition into the hdb and reloads the hdb, rdb, idb and gateway (§2).
Every process records its inbound connections in .clients.clients, with counts of queries,
errors and bytes returned (di.clienttracking, wired in by di.torq). Ask the gateway after a few
queries:
q -q <<'EOF'
h:hopen`$"::5306:",getenv`TORQXCRED;
show h"select ipa,u,startp,lastp,hits,errs,sz,live:not null w from .clients.clients";
\\
EOF- tickerplant1 records connections only; its query and publish path isn't touched.
- Ticks (
upd) skip client tracking on chainedtp1, rdb1 and wdb1. - Each connection shows one error at connect time: the connecting process asks for
.proc.getattributes[], which these processes don't define.
Every process except the tickerplants also publishes a heartbeat row every 30s
(di.torq.heartbeat, wired in by di.torq). tickerplant1, chainedtp1, stp1 and sctp1 publish none,
as in TorQ. Nothing subscribes by default. To watch them, set heartbeatsubscribeenabled = true and
heartbeatsubscribetypes (proctypes, or ALL) in a process's settings; the process must also connect
to those types (connections, startup = true). It then flags processes whose heartbeats stop
arriving in .m.di.0torq.0heartbeat.hb. Or subscribe from a q session, which then shows rdb1's
heartbeat every 30s:
upd:{[t;x] show x};
h:hopen`$"::5304:",getenv`TORQXCRED;
h(`.ps.subscribe;`heartbeat;`);As in the FSP, the tickerplant type is config only, one type at a time. The default is segmented:
feed1 → stp1 (segmentedtp) → wdb1
→ sctp1 (segmentedchainedtp, loggingmode parent) → rdb1
To run the classic tickerplant instead:
| File | Segmented (default) | Classic |
|---|---|---|
rdb1.toml tickerplanttypes |
"segmentedchainedtp" |
"chainedtp" |
wdb1.toml tickerplanttypes |
"segmentedtp" |
"tickerplant" |
feed1.toml connections |
["segmentedtp"] |
["tickerplant"] |
process.csv startwithall |
stp1, sctp1 1; tickerplant1, chainedtp1 0 |
tickerplant1, chainedtp1 1; stp1, sctp1 0 |
Subscribers use .sub.subscribe, which handles either type. With autoreconnect = true (default.toml), rdb1
and wdb1 resubscribe when their tickerplant comes back; sctp1 exits if stp1 goes, so restart stp1 then sctp1.
feed1 resumes publishing once di.torq.servers reconnects it (the 10s retry). A resubscribe does not replay, so a
subscriber misses what its tickerplant took while it was away; restart it to rebuild from the logs. stp1 logs under $KDBTPLOG
(tplog/stp1_<date>).
tickerlogreplay1 rebuilds a day from stp1's logs into hdbreplay/, then exits. Pick the run on the command
line, as in TorQ: any key in tickerlogreplay1.toml can be given as -<key>:
torqx.sh start tickerlogreplay1 -tplogdir tplog/stp1_<date> # into hdbreplay/
torqx.sh start tickerlogreplay1 -tplogdir tplog/stp1_<date> -hdbdir hdb # into the live hdbReplaying into the live hdb replaces that date's partition (clean); reload the hdb afterwards.
housekeeping1 archives a day's directory to tplog/stp1_<date>.tar.gz once it is a day old. Restore it
in place before replaying (the archive holds the absolute path):
tar -xzf tplog/stp1_<date>.tar.gz -C /torqx.sh stop # stop the whole stack
torqx.sh status # all downFor production, the same process.csv drives torqx.sh export-systemd, which emits one
systemd --user unit per process (journald logging, Restart=on-failure) — that's the deploy
path; tmux mode (§5) is dev-only.