Qorus Integration Engine®  4.0.3.p2_git
Debugging Qorus Interfaces

The user code of Qorus interfaces may be debugged using Qore's qdbg-remote command line utility, a debugger client program that uses the WebSocket protocol to connect to a remote Qorus server instance that serves as a WebSocket-based debug server.

Note
Only user code can be debugged by default.

Debugging Local Interfaces

To debug local interfaces, i.e. interfaces not running in separate processes but rather in qorus-core: Qorus Core Cluster Process (either for compatibility reasons or to reduce memory usage), use qdbg-remote to connect to qorus-core: Qorus Core Cluster Process using the instance's URL with the ws:// scheme and debug as the URI path

See also
Qorus Connection Provider Environment Variable for Debugging for environment variables to set to be able to use URL aliases for debugging

The following is an example of debugging a local (i.e. non-remote) service called test-debug_service:

$ qdbg-remote ws://localhost:8001/debug
connected to debug server "ws://localhost:8001/debug": Qorus Integration Engine v4.0.0_git (build 4742aa89eeb5514323bdadf3bcc67bb581206e7c) instance "qorus-4.0"; "help" for help
qdbg> ver
  client :
    class : DebugCommandLineRemote
  host :
    class : QorusWebSocketDebugProgramControl
qdbg> program list
    1 : qorus-core                      thr: 23 dbg: 0/0
    2 : Util.qm                         thr:  0 dbg: 0/0
    3 : Mime.qm                         thr:  0 dbg: 0/0
    .....
   50 : Qore::WebUtil::TextTemplateBase thr:  0 dbg: 0/0
   51 : prop:4.0                        thr:  0 dbg: 1/0
   52 : test-debug_service:1.0          thr:  0 dbg: 1/0

Debugging Remote Interfaces

To debug remote interfaces running in their own separate process, add the process name listed with qctl ps to the URI path as in the following example.

For example to debug a remote job named test-debug_job, first get the unique process name using qctl ps as in the following example:

$ qctl ps
active cluster processes:
  NAME                                NODE  HOST:PID    TYPE           QUEUE URL                 MEMORY STATUS
+ qorus-master                        node1 notey:31367 (qorus-master) tcp://127.0.0.1:40683  79.96 MiB OK
+ qorus-core                          node1 notey:31382 (qorus-core)   tcp://127.0.0.1:33093 323.82 MiB OK
+ qdsp-omq                            node1 notey:31398 (qdsp)         tcp://127.0.0.1:44477  97.51 MiB OK
+ qwf-TEST-DEBUG_WORKFLOW-v1.0-2      node1 notey:31936 (qwf)          tcp://127.0.0.1:45253 181.08 MiB OK
+ qjob-test-debug_job-v1.0-1          node1 notey:31784 (qjob)         tcp://127.0.0.1:46857 170.84 MiB OK

Then connect the debugger to the process using its Qorus process name qjob-test-debug_job-v1.0-1 as in the following example:

$ qdbg-remote ws://localhost:8001/debug/qjob-test-debug_job-v1.0-1
connected to debug server "ws://localhost:8001/debug/qjob-test-debug_job-v1.0-1": qjob-test-debug_job-v1.0-1; "help" for help
qdbg> ver
  client :
    class : DebugCommandLineRemote
  host :
    class : QorusDistributedDebugProgramControlSource
qdbg> program list
    1 : qjob                    thr:  5 dbg: 0/0
    2 : Util.qm                 thr:  0 dbg: 0/0
    3 : Mapper.qm               thr:  0 dbg: 0/0
    ...
   35 : PgsqlSqlUtil.qm         thr:  0 dbg: 0/0
   36 : test-debug_job:1.0      thr:  0 dbg: 1/0

Providing Explicit Source Code Locations to the Qorus Debugger

Qorus debug servers running in qorus-core: Qorus Core Cluster Process or in interface programs can also provide source code listings for running interfaces. By default, the source code listings are procided as retrieved from the system DB schema. If the source code for a running interface being debugged has been updated in the database without resetting the running interface program, then the source code listings provided by the Qorus debug servers will be out of date.

The following example shows how the debugger server can be given an explicit source code location in case an interface currently being debugged has been updated in the database and the running interface was not reloaded:

qdbg> program 36
program context set to "36"
qdbg> program file /home/user/work/qore/qorus-devel/test/debug/test-debug_job-v1.0.qjob
sha1: 01f4a8cebffc08dc4546f6cee2a5b05258529704
 1: # -*- mode: qore; indent-tabs-mode: nil -*-
 2:
 3: # name: test-debug_job
 4: # version: 1.0
 5: # desc: Test debugging
 6: # author: Tomas Mandys
 7: # schedule: 0 2 * * *
 8: # define-group: Test-debug: Test debug
 9: # groups: Test-debug
10: # constants: test-debug_const
11: # functions: test-debug_func
12: # classes: test-debug_class
13: %require-types
14: %new-style
15:
16: sub run() {
17:         int max_ms = 10000;
18:         int i=0;
19:         int stamp = clock_getmillis();
20:         getHello();
21:         while (clock_getmillis() - stamp < max_ms) {
22:             #usleep(100);  # yield
23:             i++;
24:         }
25: }
26:
27: # END

Qorus Connection Provider Environment Variable for Debugging

When QorusConnectionProvider is listed in the QORE_CONNECTION_PROVIDERS environment variable, the "qorus" alias can be used to connect to the local Qorus instance as a shortcut for the local URL.

Example QorusConnectionProvider Usage:
$ export QORE_CONNECTION_PROVIDERS=QorusConnectionProvider
$ qdbg-remote qorus
connected to debug server "ws://localhost:8001/debug": Qorus Integration Engine v4.0.0_git (build 4742aa89eeb5514323bdadf3bcc67bb581206e7c) instance "tma-4.0"; "help" for help
qdbg> quit
$ qdbg-remote qorus/qwf-TEST-DEBUG_WORKFLOW-v1.0-2
connected to debug server "ws://localhost:8001/debug/qwf-TEST-DEBUG_WORKFLOW-v1.0-2": qwf-TEST-DEBUG_WORKFLOW-v1.0-2; "help" for help
qdbg>
Note
  • All Qorus remote connections can be used as well as URL aliases; "qorus" is the automatic connection name that specifies the local Qorus server
  • In this case (and as a part of the setup of any Qorus installation), the Qorus module directory must be set in the QORE_MODULE_DIR environment variable as well to find the Qorus connection provider module QorusConnectionProvider.qm at runtime.
See also