Skip to main content

max / makenotwork

seed: run --seed-examples via systemd-run in the testnot seed script Shell-sourcing the service EnvironmentFile (`. /etc/mnw/makenotwork.env`) broke on env values containing shell metacharacters (the DB password), so DATABASE_URL never loaded and the seed panicked with MissingDatabaseUrl. Run the binary via `systemd-run -p EnvironmentFile=... -p User=deploy` instead: systemd parses KEY=value literally, exactly as the real service does. Verified end-to-end on testnot (full catalog + media seeded). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-07-12 00:53 UTC
Commit: ca7e2b3655000af46c635b18d4553045370c7912
Parent: 7a3d9d2
1 file changed, +10 insertions, -6 deletions
@@ -59,13 +59,17 @@ BEGIN
59 59 END \$\$;
60 60 SQL
61 61
62 - # Run the binary as the app user with the service env sourced and the seed
63 - # opt-in flag set. `--seed-examples` applies migrations to the empty schema,
64 - # runs the guarded seed, and exits(0) before the server binds a port — so this
65 - # is safe to run while the service is stopped.
62 + # Run the binary as the app user with the seed opt-in flag set.
63 + # `--seed-examples` applies migrations to the empty schema, runs the guarded
64 + # seed, and exits(0) before the server binds a port — so this is safe to run
65 + # while the service is stopped. Use systemd-run with the service's own
66 + # EnvironmentFile rather than shell-sourcing it: systemd parses `KEY=value`
67 + # literally, so secrets containing shell metacharacters (e.g. the DB password)
68 + # load correctly, whereas `. env` would choke on them.
66 69 log "migrating + seeding the example catalog"
67 - ts_ssh "cd $BIN_DIR && sudo -u $SEED_USER env ALLOW_EXAMPLE_SEED=1 \
68 - bash -c 'set -a; . $ENV_FILE; set +a; exec ./$BIN_NAME --seed-examples'"
70 + ts_ssh "systemd-run --pipe --wait --collect --service-type=exec \
71 + -p EnvironmentFile=$ENV_FILE -p WorkingDirectory=$BIN_DIR -p User=$SEED_USER \
72 + -E ALLOW_EXAMPLE_SEED=1 $BIN --seed-examples"
69 73
70 74 log "starting $SERVICE"
71 75 ts_ssh "systemctl start $SERVICE"