{"id":31579063,"url":"https://github.com/peakk2011/kavin","last_synced_at":"2026-05-08T07:32:25.725Z","repository":{"id":317308251,"uuid":"1066537745","full_name":"Peakk2011/Kavin","owner":"Peakk2011","description":"The generic Node.js process watcher","archived":false,"fork":false,"pushed_at":"2025-09-30T05:55:16.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-30T06:08:55.587Z","etag":null,"topics":["assembly","auto-restart","c","dev-tools","development","electron","file-watcher","low-level-programming","nodejs","nodemon","peakk2011","performance"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Peakk2011.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-29T16:09:21.000Z","updated_at":"2025-09-30T05:55:19.000Z","dependencies_parsed_at":"2025-09-30T06:08:57.561Z","dependency_job_id":"0da9efc9-b052-4b98-8073-16ead79ff08b","html_url":"https://github.com/Peakk2011/Kavin","commit_stats":null,"previous_names":["peakk2011/kavin"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Peakk2011/Kavin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Peakk2011%2FKavin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Peakk2011%2FKavin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Peakk2011%2FKavin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Peakk2011%2FKavin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Peakk2011","download_url":"https://codeload.github.com/Peakk2011/Kavin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Peakk2011%2FKavin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278517918,"owners_count":26000175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","auto-restart","c","dev-tools","development","electron","file-watcher","low-level-programming","nodejs","nodemon","peakk2011","performance"],"created_at":"2025-10-05T20:46:07.135Z","updated_at":"2025-10-05T20:46:12.148Z","avatar_url":"https://github.com/Peakk2011.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./assets/Logo.png\" width=\"150\" /\u003e\n\n# Kavin\n\nThe generic Node.js process watcher written in C and Assembly\n\n## Quick Install\n```bash\ngit clone https://github.com/Peakk2011/Kavin.git\ncd Kavin\nmake\n```\n\nIt's a better alternative for viewing files that works like nodemon and has some nice differences.\n\n## Why Kavin over nodemon?\n\n| Feature | Kavin | nodemon |\n|---------|-------|---------|\n| **Startup Time** | \u003c10ms | ~200ms |\n| **Memory Usage** | ~2MB | ~30MB |\n| **CPU Usage** | ~0.1% | ~1-2% |\n| **Binary Size** | ~18KB | ~1.5MB (+ Node.js) |\n| **Dependencies** | None | Node.js + npm packages |\n| **Language** | C/ASM | JavaScript |\n\n### Key Advantages\n\n- **15-20x faster startup** - Made with the low-level programming language, the execution time can be done immediately.\n- **15x less memory** - No Node.js runtime overhead  \n- **10-20x less CPU** - Minimal resource consumption  \n- **Zero dependencies** - Single executable, works anywhere  \n- **Universal** - Works with Node.js, Deno, Bun, Python, Go, Rust, anything  \n- **Smart process management** - Kills entire process tree cleanly (no zombies)  \n- **Graceful shutdown** - SIGTERM → wait → SIGKILL if needed  \n- **Crash recovery** - Auto-restarts if process dies unexpectedly  \n\n### When to use Kavin\n\n**Choose Kavin if you want:**\n- Maximum speed and minimum resource usage\n- Lightweight tool that does one thing extremely well\n- No Node.js dependency (works with any language/runtime)\n- Simple single-file watching\n    - Like you want to live some file and fetch some command it will auto to run\n    - Example: `./kavin \"npm start\" src/main.js`\n\n**Choose nodemon if you need:**\n- Complex directory watching with patterns\n- Advanced configuration via nodemon.json\n- Plugin ecosystem and extensive options\n\n**Think of it this way:**\n\nThinking this way will give you a bigger picture, not just technical information.\n\n`nodemon` = Swiss Army knife (feature-rich, versatile)  \n`Kavin` = Scalpel (sharp, fast, precise)\n\n## Installation\n\n### Build from source\n\n```bash\nmake\n```\n\nThis creates the `kavin` executable in your current directory.\n\n### Install globally (optional)\n\n```bash\nmake install\n```\n\n## Usage\n\n### Basic usage\n\n```bash\n./kavin \"npm start\" src/main.js\n./kavin \"node server.js\" server.js\n./kavin \"bun run dev\" index.ts\n```\n\n### Command format\n\n```bash\n./kavin \"\u003ccommand\u003e\" [file_to_watch]\n```\n\n- `\u003ccommand\u003e` - Any shell command to run\n- `[file_to_watch]` - File to watch (default: `src/main.js`)\n\n## How it works\n\n```\n┌─────────────────────────────────────────┐\n│  1. Start: ./kavin \"npm start\" main.js  │\n└─────────────────┬───────────────────────┘\n                  │\n                  ▼\n         ┌────────────────┐\n         │ Fork \u0026 Execute │\n         │  \"npm start\"   │\n         │   (PID: 1234)  │\n         └────────┬───────┘\n                  │\n        ┌─────────▼──────────┐\n        │   Watch main.js    │\n        │  Check every 0.1s  │\n        └─────────┬──────────┘\n                  │\n          ┌───────┴────────┐\n          │                │\n    File changed?    Process died?\n          │                │\n         Yes              Yes\n          │                │\n          ▼                ▼\n    ┌──────────────────────────┐\n    │  1. SIGTERM → wait 2s    │\n    │  2. SIGKILL if alive     │\n    │  3. Fork new process     │\n    └──────────────────────────┘\n                  │\n                  ▼\n          ┌───────────────┐\n          │ Restart count │\n          │     +1        │\n          └───────────────┘\n```\n\n### What happens on file change:\n\n1. **Detect change** - `stat()` checks file modification time\n2. **Kill gracefully** - Send `SIGTERM` to process group\n3. **Wait patiently** - Give 2 seconds to clean up\n4. **Force kill** - Send `SIGKILL` if still alive\n5. **Restart** - Fork new process immediately\n6. **Track** - Increment restart counter\n\n### Process Management\n\n**Process Group Isolation:**\n```c\nsetpgid(0, 0);          // Child creates new process group\nkill(-pid, SIGTERM);    // Kill entire group\n```\n\nThis ensures:\n- All child processes are killed (npm → node → your app)\n- No zombie processes left behind\n- Clean process tree termination\n\n## Examples\n\n### Electron apps\n\n```bash\n./kavin \"npm start\" src/main.js\n./kavin \"electron .\" src/main.js\n./kavin \"electron-forge start\" src/index.js\n```\n\n### Node.js servers\n\n```bash\n./kavin \"node server.js\" server.js\n./kavin \"npm run dev\" src/index.js\n./kavin \"ts-node src/app.ts\" src/app.ts\n```\n\n### Bun / Deno\n\n```bash\n./kavin \"bun run dev\" src/app.ts\n./kavin \"deno run --allow-net server.ts\" server.ts\n```\n\n### Other languages\n\n```bash\n./kavin \"python app.py\" app.py\n./kavin \"go run main.go\" main.go\n./kavin \"cargo run\" src/main.rs\n```\n\n## Real-world Benefits\n\n### Development Workflow\n\n**Before Kavin:**\n```bash\n$ npm start\n# ... edit code ...\n^C\n$ npm start\n# ... edit code ...\n^C\n$ npm start\n# Repeat 100x per day 😫\n```\n\n\u003e There may be other tools that don't always require this. This example is a general explanation.\n\n**With Kavin:**\n```bash\n$ ./kavin \"npm start\" src/main.js\n# ... edit code, save ...\n# Auto-restarts!\n# ... edit code, save ...\n# Auto-restarts!\n# Keep coding!\n```\n\n### Performance Impact\n\nOn a typical development session (8 hours):\n- **100 manual restarts** → 100 × 5 seconds = **8 minutes wasted**\n- **With nodemon** → 30MB RAM + 1-2% CPU constantly\n- **With Kavin** → 2MB RAM + 0.1% CPU constantly\n\n**Result:** Kavin saves time, battery, and system resources.\n\n## Configuration\n\nEdit `watcher/watcher.h` to change defaults:\n\n```c\n#define FILEPATH \"src/main.js\"         // Default file to watch\n#define CHECK_INTERVAL_US 100000       // Check interval (0.1s)\n```\n\nThen rebuild:\n```bash\nmake rebuild\n```\n\n## Project Structure\n\n\u003e This structure is a basic representation of the project structure. There may be additional structures and folders.\n\n```\nkavin/\n├── main.c                      # Entry point, argument parsing\n├── watcher/                   \n│   ├── watcher.c/.h            # File watching logic (stat, mtime)\n│   ├── watcher_actions.c/.h    # Restart, kill process tree\n│   └── process.c/.h            # Process management (fork, exec)\n├── Makefile                    # Build automation\n├── README.md\n└── LICENSE\n```\n\n## Development\n\n### Build commands\n\n```bash\nmake           # Build optimized binary\nmake clean     # Remove build artifacts\nmake rebuild   # Clean + build\nmake install   # Install to /usr/local/bin\n```\n\n## Troubleshooting\n\n### Process not killing properly\n\nKavin uses process groups to kill entire trees. If you still see zombie processes:\n\n```bash\n# Check for orphaned processes\nps aux | grep node\n\n# Kill manually if needed\nkill -9 \u003cpid\u003e\n```\n\n### File changes not detected\n\nMake sure the file path is correct:\n\n```bash\n# Wrong (if run from project root)\n./kavin \"npm start\" main.js\n\n# Correct\n./kavin \"npm start\" src/main.js\n```\n\n### Permission denied\n\nMake the binary executable:\n\n```bash\nchmod +x kavin\n```\n\n### High CPU usage\n\nIf you see high CPU, your editor might be creating temp files. Adjust check interval:\n\n```c\n#define CHECK_INTERVAL_US 200000  // Check every 0.2s instead\n```\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details\n\n## Contributing\n\nPull requests welcome! Please keep the philosophy of simplicity and speed.\n\n## Author\n\nMade by Mint teams\n\n---\n\n**Star ⭐ this repo if Kavin saves you time!**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeakk2011%2Fkavin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeakk2011%2Fkavin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeakk2011%2Fkavin/lists"}