Operating#
- Start, stop and status.
- Linux:
./crushbalance_init.sh start|stop|restart|status(orsystemctl …under systemd, Install on Linux). - Windows:
net start|stop "CrushBalance Server". - A stop unbinds every listener at once, lets open connections finish for at most 3 seconds, resets the rest, saves the GeoIP cache and the sticky pins, and exits after about 4 seconds.
- Only one CrushBalance can use a prefs directory: a second one exits with code 6 ("another CrushBalance (pid …, started …) is using …").
- Linux:
- Monitoring with
/healthz.GET https://<host>:8090/healthzneeds no login (the admin address allowlist still applies). It answers200 okwhen CrushBalance is licensed, not in safe mode or stopping, every enabled and usable listener is bound, and every bound listener has at least one routable endpoint; otherwise503 degraded. For examplecurl --cacert admin.pem https://balancer:8090/healthz(or-kwith the generated certificate). - Prometheus
/metrics. Off by default (404). Settings › Server › Prometheus metrics › Generate token shows a bearer token once; only its hash is stored. Scrapehttps://<host>:8090/metricswithAuthorization: Bearer <token>; the scraper must be allowed byadmin_allowed_ips. Rotate or turn it off in the same place. A Prometheus job:
Labels carry listener and endpoint ids, never names.- job_name: crushbalance scheme: https authorization: type: Bearer credentials_file: /etc/prometheus/crushbalance.token tls_config: ca_file: /etc/prometheus/crushbalance-admin-ca.pem static_configs: - targets: ['balancer.example.com:8090'] - Logs.
CrushBalanceServer.login the working directory (log_file), rotated atlog_max_size_mb(50 MiB) intolog_max_files(9) archives. Each line isyyyy/MM/dd_HH:mm:ss:SSS|CATEGORY|LEVEL|message.log_level(defaultinfo) sets every category;log_categoriesoverrides single ones, for exampleconn=warn,health=debug. Both apply at once (Settings › Logging). Categories:server,config,conn,route,health,tls,http,proxy,security,admin,geoip,license, andaudit(alwaysinfo).connwrites one line per closed connection. At high connection rates setconn=warn, so the audit lines in the same file are not rotated away quickly.- The Logs page shows a live tail of the newest 5,000 lines, with level, category and text filters; its Audit mode shows the newest 1,000 audit entries.
- Backups and restore.
- Every new version of
prefs.XMLthat loads as a CrushBalance 27 file (a save, or a hand edit, also one with errors) is copied tobackup/prefs-<yyyyMMdd-HHmmss-SSS>.XML(the newest 50 are kept), so the newest backup is always the current configuration, hand edits included. - From the UI: System › Backups › Restore. It keeps the current admin password, metrics token and registration; the replaced version stays available as a backup.
- By hand: copy a backup file over
prefs.XML. CrushBalance applies it within about 2 seconds, exactly as it is, credentials included. - Backups hold encrypted passwords; restoring them needs the same
crushbalance.key.
- Every new version of
- Hand edits and
-check-config.- CrushBalance checks
prefs.XMLevery 2 seconds (and hashes it every 60 s) and applies a changed file without a restart. Comments are removed at the next save. - The file is XML 1.0. A file whose declaration names another version (
<?xml version="1.1"?>) is refused like a file that is not well-formed:PREFS_PARSE, "the XML declaration must say version="1.0"" (at startup that means safe mode). - Validate first:
java -jar CrushBalance.jar -check-config(or-check-config <file>for a copy). It prints every finding as[ERROR] path: messageand a summary, and exits 0, or 3 on an error. It never writes. - A file with errors still loads, with the notice "Configuration errors" (System › Configuration issues): only the faulty part is affected. At startup a listener with an error is not started, an endpoint with an error is not used, a rule list with an error denies everyone, and a global key with an error takes its default; on a reload the previous definition of that part stays in force.
- A file that cannot be parsed while CrushBalance runs: the running configuration is kept, a banner reports it, and UI saves are refused (409) until you fix it or overwrite it from the UI (the invalid file is then kept as
backup/…-invalid.XML).
- CrushBalance checks
- Safe mode and how to leave it. If at startup
prefs.XMLcannot be parsed, is damaged, or was written by a newer CrushBalance, it is not modified, and CrushBalance starts in safe mode:- no listener is bound, but the process keeps running (systemd does not loop);
- the admin UI accepts the admin password of the newest valid backup and shows the reason, with the line and column, the backups, and the configuration log;
- leave it by restoring a backup in the UI (refused with "would lock out" if that backup's
admin_allowed_ipsexcludes your address), by fixing the file by hand (CrushBalance re-checks it every 2 seconds and starts normally once it is valid), or by copying a backup overprefs.XML; java -jar CrushBalance.jar -check-configprints the details;- without any valid backup the admin shows only a notice page: "CrushBalance is in safe mode: prefs.XML cannot be used. Run "java -jar CrushBalance.jar -check-config" on the server for details." Fix or replace the file; deleting it starts a new, empty configuration (setup again).
- Sticky pins across restarts. Every live pin (client address and
CrushAuthcookie) is saved tosticky-pins.datevery 60 seconds when pins changed and at shutdown, and restored at startup, so clients return to the same backend after a restart. The file holds hashed keys only, never an address or a cookie. Pins idle longer than the listener'ssticky_ttlare dropped, downtime included. A crash loses at most 60 seconds of pin changes. - The key file and moving to another host.
crushbalance.keyencrypts the passwords inprefs.XML(keystore, probe and GeoIP passwords), derives the passwords of the generated certificates and keys the pin file.- Back it up together with the prefs directory.
- To move to another host, copy
prefs.XMLandcrushbalance.key(the generated certificates andsticky-pins.datare optional). - Without the original key, encrypted values cannot be decrypted (notice "Secrets cannot be decrypted"; restore the original key file, or enter the passwords again), generated certificates are regenerated (new fingerprint), and the pin file is ignored. The licence and the admin password are not affected.
- Certificate renewal. Replace the keystore file (listener
tls_keystoreoradmin_keystore); CrushBalance checks it every 60 seconds and uses the new certificate for new connections. Expiry warnings appear 30, 7 and 1 days ahead (listeners) and from 30 days ahead (admin). With certbot, a deploy hook can build the PKCS12 file:
The password in the pass file must equal the listener's keystore password (one password for the keystore and its key). When CrushBalance runs as a non-root user (Install on Linux), alsoopenssl pkcs12 -export -in "$RENEWED_LINEAGE/fullchain.pem" -inkey "$RENEWED_LINEAGE/privkey.pem" \ -name crushbalance -passout file:/etc/crushbalance/web.p12.pass -out /etc/crushbalance/web.p12.new \ && chmod 600 /etc/crushbalance/web.p12.new && mv /etc/crushbalance/web.p12.new /etc/crushbalance/web.p12chown crushbalance: /etc/crushbalance/web.p12.newbefore themv, so the service user can read the file. Generated certificates renew themselves 30 days before they expire. A listener that was not started because its keystore was unusable starts at the next save, hand edit or restart.