com um clique
rebuild-addon
// Rebuild the C++ native addon after making changes to http_checker.cpp
// Rebuild the C++ native addon after making changes to http_checker.cpp
Create a well-structured GitHub issue for Jetmon work
Create a PR for the current branch based on the PR template
Debug memory issues in Jetmon workers and identify leaks
Run, debug, and test Jetmon using the Docker development environment
| name | rebuild-addon |
| description | Rebuild the C++ native addon after making changes to http_checker.cpp |
| allowed-tools | Bash(npm run*), Bash(node-gyp*), Bash(docker*), Bash(cp*), Bash(ls*), Read, Glob, Grep |
Use this skill after making changes to the C++ native addon (src/http_checker.cpp or src/http_checker.h).
/rebuild-addon - Rebuild the addon and restart Jetmon/rebuild-addon docker - Rebuild inside Docker container/rebuild-addon test - Rebuild and run a quick testnpm run rebuild-run
This runs node-gyp rebuild, copies the addon to lib/, and starts Jetmon.
node-gyp rebuild
cp build/Release/jetmon.node lib/
node lib/jetmon.js
docker compose exec jetmon npm run rebuild-run
Or manually inside the container:
docker compose exec jetmon bash
cd /jetmon
node-gyp rebuild
cp build/Release/jetmon.node lib/
node lib/jetmon.js
After building, verify the addon loads correctly:
node -e "require('./lib/jetmon.node'); console.log('Addon loaded successfully');"
Create a test script:
// lib/test-addon.js
var checker = require( './jetmon.node' );
checker.http_check( 'https://wordpress.com', 80, 0, function( index, rtt, http_code, error_code ) {
console.log( 'Index:', index );
console.log( 'RTT (microseconds):', rtt );
console.log( 'HTTP Code:', http_code );
console.log( 'Error Code:', error_code );
process.exit( 0 );
});
Run it:
node lib/test-addon.js
index: The index passed to the check (0 in this case)rtt: Round-trip time in microsecondshttp_code: HTTP response code (200 for success)error_code: 0 for success, non-zero for errors| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Connection failed |
| 2 | Timeout |
| 3 | SSL error |
| 4 | DNS resolution failed |
| 5 | Too many redirects |
| File | Purpose |
|---|---|
src/http_checker.cpp | Main HTTP checking implementation |
src/http_checker.h | Header with class definition |
binding.gyp | Node-gyp build configuration |
Missing OpenSSL headers:
fatal error: openssl/ssl.h: No such file or directory
Solution: Install OpenSSL development package:
# macOS
brew install openssl
# Ubuntu/Debian
apt-get install libssl-dev
Node version mismatch: If you see ABI version errors, clean and rebuild:
node-gyp clean
node-gyp rebuild
Addon not found:
Error: Cannot find module './jetmon.node'
Solution: Copy the built addon:
cp build/Release/jetmon.node lib/
Symbol errors: Usually indicates Node.js version changed. Rebuild the addon.
In src/http_checker.cpp, set:
#define DEBUG_MODE 1
Debug output goes to stderr.
For memory leaks, use Valgrind (Linux):
valgrind --leak-check=full node lib/jetmon.js
The binding.gyp file configures the build:
{
"targets": [{
"target_name": "jetmon",
"sources": ["src/http_checker.cpp"],
"include_dirs": ["<!(node -e \"require('nan')\")"],
"libraries": ["-lssl", "-lcrypto"]
}]
}
Key settings: