2
0
Fork 0
forked from zynk/zynk

Hot reload preserves IRC session (nick, channels, voice). (0.39.0)

This commit is contained in:
Johannes Findeisen 2026-07-21 16:17:43 +02:00
commit 738323ebaf
3 changed files with 43 additions and 51 deletions

View file

@ -14,7 +14,7 @@ A single-file IRC bot in C. Features a key-value store backed by SQLite3, weathe
- **AI Queries**: Ask questions via `!ai` or by addressing the bot; powered by `opencode`
- **Code Changes**: AI-powered code editing with auto-recompile and hot reload
- **Chat Greetings**: Responds to `hi`, `hello`, `hey`, `bye`, and more
- **Hot Reload**: Reload or restart without disconnecting from IRC
- **Hot Reload**: Reload or restart without leaving channels, losing your nick, or dropping voice mode
- **TLS**: Secure connections via OpenSSL
- **Rate Limiting**: Per-nick protection against spam
- **Reconnection**: Auto-reconnect with exponential backoff
@ -248,8 +248,8 @@ The calculator uses `bc -l` (POSIX arbitrary-precision calculator with the math
| Command | Description |
|-----------------------|-------------------------------------------------------------------------------------|
| `!reload` | Hot reload (save TLS state, fork new process) |
| `!restart` | Restart the bot |
| `!reload` | Hot reload (preserve IRC session, fork-in-place) |
| `!restart` | Restart the bot (preserves session, same as !reload) |
| `!rebuild [pull]` | Rebuild and restart (ops only, in channels; `pull` runs Git pull before rebuilding) |
| `!code <instruction>` | Make AI-powered code changes |
@ -272,7 +272,7 @@ Data is stored in `zynk.db` (SQLite3) in the working directory. The bot creates
## Architecture
`zynk` uses a single `poll()` loop with a 100 ms timeout. AI queries fork a child process that runs the `opencode` CLI; the parent picks up the result on the next poll iteration. SQLite3 is loaded at runtime via `dlopen` to avoid a compile-time dependency. The bot supports hot reload: `!reload` and `!restart` save TLS session state, fork a new process with the inherited socket, and resume without dropping from IRC.
`zynk` uses a single `poll()` loop with a 100 ms timeout. AI queries fork a child process that runs the `opencode` CLI; the parent picks up the result on the next poll iteration. SQLite3 is loaded at runtime via `dlopen` to avoid a compile-time dependency. The bot supports hot reload: `!reload` and `!restart` fork without exec, so the child inherits the live socket and SSL session — the bot stays connected, keeps its nick, and remains voiced in channels. `!rebuild`/`!code` do a clean QUIT+exec since the binary changed on disk.
## License