inspector
This option was added in Profound.js version 5.2.0. It is not valid on Windows – setting it to true there causes a configuration error at startup.
Description
When this option is set to true, signal handlers are added to the server that can be used to trigger heap snapshots and CPU profiles using Node’s Inspector API.
To send signals to the server process you first need the server process id, which is written to the server’s standard output log at startup. Signals are sent with the kill command from a shell; on IBM i, run the command from a PASE shell.
Example: Heap Snapshot
A heap snapshot dumps the contents of Node’s V8 heap for later inspection, which is useful for troubleshooting memory leaks or excessive memory use.
A heap snapshot can take a minute or more, depending on the size of the heap, and the Node.js event loop is blocked while it runs – the server cannot respond to any requests until it completes. The snapshot also requires memory twice the size of the heap; if there is not enough memory available, the server process may be killed by the operating system.
To trigger a heap snapshot, send the SIGHUP signal to the server process:
Trigger heap snapshot
kill -HUP <PROCESS_ID>When the snapshot starts, the server writes this message to the standard output log:
Starting heap snapshot.Heap snapshots are written to INSTALLATION_DIRECTORY/profiler-reports/profoundjs.heapsnapshot, overwriting any previous snapshot. When the process completes, the server writes:
Heap snapshot written to INSTALLATION_DIRECTORY/profiler-reports/profoundjs.heapsnapshotMessages are written to the standard error log if anything prevents the heap snapshot from running. Snapshots can be viewed in Chrome DevTools.
Example: CPU Profiler
The CPU profiler collects data on CPU usage, which is useful for troubleshooting high CPU usage or long-running processes. It must be started, allowed to run while the server processes requests, and then ended in order to produce a report.
To start the CPU profiler, send the SIGUSR1 signal to the server process:
Start CPU profiler
kill -USR1 <PROCESS_ID>The server writes this message to the standard output log:
CPU profiler started.After allowing the server to process the requests you want data for, end the profiler by sending the SIGUSR2 signal:
End CPU profiler
kill -USR2 <PROCESS_ID>CPU profiles are written to INSTALLATION_DIRECTORY/profiler-reports/profoundjs.cpuprofile, overwriting any previous profile. When the process completes, the server writes:
CPU profiler ended.
CPU profile written to INSTALLATION_DIRECTORY/profiler-reports/profoundjs.cpuprofileMessages are written to the standard error log if anything prevents the CPU profiler from running. Profiles can be viewed in Chrome DevTools.
Enabling in config.js
inspector: trueFor information on how to modify this setting, see Configuration File.