Skip to content

Standalone Binary

iHorizon can be built into a single executable file. It contains the code, the language files, the SVG templates and every file of src/assets (fonts, emojis, video templates), so the machine that runs it needs neither Bun, nor node_modules, nor the source code. The same file runs the shard manager and every shard.

Building the binary

The installation script can do all of this for you: choose the standalone binary when it asks how to run iHorizon, and it builds the binary, installs it in ~/ihorizon-bin with your .env, data and version files, and starts it under pm2.

To do it by hand, from a checkout with the dependencies installed (see Pre-requisites):

bun run build:binary

The binary is written to dist/ihorizon, for the platform you build on. To build for another platform, pass a Bun target:

bun run build:binary --target bun-linux-arm64
bun run build:binary --target bun-windows-x64 --outfile dist/ihorizon.exe

Build on the platform that runs the bot

Image rendering uses a native module, which is embedded for the platform the build runs on. A binary built for another platform starts and answers commands, but can only render images through the HorizonGateway.

Running the binary

Put the binary in an empty folder with your .env file (see Configuration), then start it from that folder:

./ihorizon

The working directory is where the bot keeps its data, exactly like a checkout:

Path Content
.env Your configuration
src/files/ The database (SQLite or JSON), logs and caches
.ihorizon/resources/ The embedded files, extracted on the first start of each build (resvg and ffmpeg need real files)
v.txt, v.old.txt The running version, used by the release notifier

Older builds' resources are removed on their own when a new build starts.

Moving an existing bot to the binary

Copy .env (or run bun run config:env first if you still use src/files/config.ts), src/files/, v.txt and v.old.txt from your checkout into the binary's folder. Without v.txt and v.old.txt, the bot takes its first start for a new release and DMs the server owners about it (unless they were already notified for this version in the database).

Updating

Build the new version and replace the binary, then restart it. git pull and bun install are not involved: the binary only changes when you rebuild it.

Limits

  • The changelog PDFs are not embedded: release announcements are sent without their attachment, unless you copy the changelogs/ folder next to the binary.
  • pm2.config.cjs (with its git pull, bun install and process cleanup) is made for a checkout. Run the binary directly instead: the installation script starts it with pm2 start ~/ihorizon-bin/ihorizon --name iHorizon --cwd ~/ihorizon-bin --interpreter none, and any service manager (systemd, a container...) works the same way.