Changeset 0f09302 in Klonkt for deploy/MULTI-INSTANCE.md


Ignore:
Timestamp:
08/21/2026 08:00:05 AM (3 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
bb9e54c
Parents:
1294c36
Message:

reset-admin wijst een instantie aan, en maakt nooit een database aan

In de gedeelde opstelling van deploy/klonkt@.service werkte het noodpad niet.
De code staat daar op /opt/klonkt en de configuratie per instantie in
/var/lib/klonkt/<slug>/.env, waar systemd hem leest via EnvironmentFile. Een
script dat je zelf start krijgt die omgeving niet: dotenv zoekt naast de code,
vindt niets, en draait zonder DATABASE_PATH.

Gemeten op een nagebouwde opstelling: 'npm run reset-admin' legde een lege
database in /opt/klonkt/storage/ -- de gedeelde codemap, die volgens de unit
juist read-only is -- en klapte daarna op 'no such table: users'. Een
stacktrace op de plek waar een aanwijzing hoort.

Drie dingen:

  • --instance <slug> leest dezelfde .env als systemd, met override, want wie de instantie aanwijst hoort te winnen van een DATABASE_PATH die nog in de shell hangt van een vorige.
  • De controle staat VOOR de import van src/config/database.js, want die maakt map en bestand aan zodra hij geladen wordt. Ontbreekt de database, dan stopt hij en noemt het pad; hij maakt er geen.
  • deploy/MULTI-INSTANCE.md noemt het commando nu, met de reden erbij. De hulppagina in de app zegt 'vanuit de projectmap', en dat klopt alleen bij een eigen checkout per instantie.

Zes tests, waaronder de geslaagde weg: het getoonde wachtwoord moet echt op de
gebruiker passen. Controleproef gedraaid -- zonder de wacht valt de test om die
eist dat er niets wordt aangemaakt.

Co-Authored-By: Claude Opus 5 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • deploy/MULTI-INSTANCE.md

    r1294c36 r0f09302  
    210210| `klonkt-update` | update the code, restart all instances |
    211211| `ls /var/lib/klonkt` | which instances exist |
     212| `cd /opt/klonkt && npm run reset-admin -- --instance <slug>` | reset a forgotten admin password |
     213
     214### Why the password reset needs `--instance`
     215
     216Every other command here names its instance, and this one is no different — but
     217the reason is easy to miss, because the app's own help page says only "run
     218`npm run reset-admin` from the project folder". That advice is written for the
     219one-instance layout, where the `.env` sits next to the code.
     220
     221Here it does not. The code is shared and read-only at `/opt/klonkt`; the
     222configuration lives at `/var/lib/klonkt/<slug>/.env`, and **systemd** reads it
     223through `EnvironmentFile=`. A script started by hand gets none of that: it looks
     224for an `.env` beside the code, finds nothing, and is left without
     225`DATABASE_PATH`. `--instance` reads the same file systemd does.
     226
     227Without it the script now stops and says which path it wanted, instead of
     228creating an empty database inside the shared code directory. If your data lives
     229somewhere other than `/var/lib/klonkt`, set `KLONKT_DATA_ROOT`.
Note: See TracChangeset for help on using the changeset viewer.