Changeset 5462bab in Klonkt
- Timestamp:
- 07/31/2026 01:52:04 PM (6 weeks ago)
- Branches:
- main
- Children:
- f434294
- Parents:
- ccaa530
- Files:
-
- 1 added
- 5 edited
-
deploy/MULTI-INSTANCE.md (modified) (1 diff)
-
scripts/install.sh (modified) (1 diff)
-
scripts/klonkt-migrate-data.sh (modified) (1 diff)
-
scripts/klonkt-refresh-updater.sh (added)
-
src/routes/admin-sites.js (modified) (1 diff)
-
src/views/pages/admin-site-edit.ejs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
deploy/MULTI-INSTANCE.md
rccaa530 r5462bab 133 133 ``` 134 134 135 **Migrated before August 2026?** Then your `klonkt-update` still restarts the 136 retired `klonkt.service`: the code updates but the running process never 137 follows, and after the next update the site can 500 on pages whose template 138 and route no longer match. Repair it once: 139 140 ```bash 141 sudo systemctl restart klonkt@<slug> # load the current code now 142 sudo bash /opt/klonkt/scripts/klonkt-refresh-updater.sh # fix the updater for good 143 ``` 144 145 The migration script does this by itself nowadays. 146 135 147 That pulls the code once into `/opt/klonkt`, reinstalls dependencies only when 136 148 `package-lock.json` changed, and restarts every instance it finds under -
scripts/install.sh
rccaa530 r5462bab 305 305 306 306 log "Update command 'klonkt-update'…" 307 cat > /usr/local/bin/klonkt-update <<EOF 308 #!/usr/bin/env bash 309 set -euo pipefail 310 D="${KLONKT_DIR}" 311 B=\$(runuser -u ${KLONKT_USER} -- git -C "\$D" rev-parse HEAD 2>/dev/null || true) 312 runuser -u ${KLONKT_USER} -- git -C "\$D" fetch --depth 1 origin ${KLONKT_BRANCH} 313 runuser -u ${KLONKT_USER} -- git -C "\$D" checkout -qf -B ${KLONKT_BRANCH} FETCH_HEAD 314 A=\$(runuser -u ${KLONKT_USER} -- git -C "\$D" rev-parse HEAD) 315 if [ "\$B" = "\$A" ]; then 316 echo "Klonkt is already up to date (\$A) — nothing to do." 317 exit 0 318 fi 319 if ! runuser -u ${KLONKT_USER} -- git -C "\$D" diff --quiet "\$B" "\$A" -- package-lock.json 2>/dev/null; then 320 runuser -u ${KLONKT_USER} -- env HOME="\$D" bash -c "cd '\$D' && npm ci --omit=dev" 321 fi 322 # Restart every instance. Each directory under the data root with an .env is one 323 # instance sharing this checkout. An install that has not been split yet has no 324 # such directories and still runs the single klonkt.service. 325 N=0 326 for d in ${KLONKT_DATA_ROOT}/*/; do 327 [ -f "\$d/.env" ] || continue 328 s=\$(basename "\$d") 329 systemctl restart "klonkt@\$s" && N=\$((N+1)) 330 done 331 if [ "\$N" = 0 ]; then 332 systemctl restart klonkt 333 echo "Klonkt updated (\$A) + restarted." 334 else 335 echo "Klonkt updated (\$A) + restarted \$N instance(s)." 336 fi 337 EOF 338 chmod +x /usr/local/bin/klonkt-update 307 # Generated by the shared script so an install and a later layout migration 308 # can never drift apart on what the updater restarts. 309 KLONKT_DIR="$KLONKT_DIR" KLONKT_USER="$KLONKT_USER" \ 310 KLONKT_DATA_ROOT="$KLONKT_DATA_ROOT" KLONKT_BRANCH="$KLONKT_BRANCH" \ 311 bash "$KLONKT_DIR/scripts/klonkt-refresh-updater.sh" 339 312 ok "klonkt-update" 340 313 -
scripts/klonkt-migrate-data.sh
rccaa530 r5462bab 135 135 run "systemctl enable --now 'klonkt@$SLUG'" 136 136 137 step "Rewriting klonkt-update for the new layout" 138 # The installer generated an updater that restarts klonkt.service — which we 139 # just retired. Left alone it would keep updating the code while never 140 # restarting the real process: half old, half new, and a 500 with no obvious 141 # cause. Rewrite it so it restarts every klonkt@<slug> instead. 142 if [ -f "$KLONKT_DIR/scripts/klonkt-refresh-updater.sh" ]; then 143 run "KLONKT_DIR='$KLONKT_DIR' KLONKT_USER='$KLONKT_USER' KLONKT_DATA_ROOT='$DATA_ROOT' bash '$KLONKT_DIR/scripts/klonkt-refresh-updater.sh'" 144 else 145 say "WARNING: scripts/klonkt-refresh-updater.sh missing in this checkout." 146 say " Update the code and run it once by hand, or every klonkt-update" 147 say " from now on will update code WITHOUT restarting the process." 148 fi 149 137 150 step "Verifying" 138 151 if [ "$DRY" = 1 ]; then -
src/routes/admin-sites.js
rccaa530 r5462bab 211 211 platforms: listPlatforms(), 212 212 parsedLinks: [], 213 apAliases: '', 213 214 error: null, 214 215 }); -
src/views/pages/admin-site-edit.ejs
rccaa530 r5462bab 217 217 <p class="form-hint"><%= t('asite.aliases_hint') %></p> 218 218 <label> 219 <textarea name="ap_aliases" rows="3" placeholder="@oud@mastodon.social https://andere-klonkt.example/ap/users/naam"><%= apAliases %></textarea> 219 <%# typeof-guard on purpose: during a deploy an old route can render this new 220 template for one request (view cache fills on first hit). A missing local 221 must degrade to an empty field, not take the whole page down with a 500. %> 222 <textarea name="ap_aliases" rows="3" placeholder="@oud@mastodon.social https://andere-klonkt.example/ap/users/naam"><%= typeof apAliases !== 'undefined' ? apAliases : '' %></textarea> 220 223 </label> 221 224 </fieldset>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)