mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
snapcraft has no per-app ulimit key and snapd owns the systemd unit, but a process may always raise its own soft open-file limit up to the hard one without privilege. The snap's Caddy service now does that before it starts Caddy, every time, which is what makes it persist across restarts and refreshes. CADDY_NOFILE may ask for a lower number; it is capped at the hard limit, a non-number is ignored, and a failure to raise is logged without stopping Caddy. tests/snapCaddyNofile6552.test.cjs runs the helper in bash with a lowered limit. It has not been run inside an installed snap here. Thanks to xet7 ! Fixes #6552.
27 lines
1.1 KiB
Bash
Executable File
27 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [[ "$PATH" != *"$SNAP_INSTANCE_NAME"* ]]; then
|
|
export PATH="${PATH/\/snap\/wekan\//\/snap\/$SNAP_INSTANCE_NAME\/}"
|
|
fi
|
|
|
|
# Get wekan/mongo settings
|
|
source $SNAP/bin/wekan-read-settings
|
|
|
|
if [ "$CADDY_ENABLED" = "true" ]; then
|
|
# If upgrading from an old WeKan snap, $SNAP_COMMON/Caddyfile may still be in
|
|
# Caddy v1 format, which Caddy 2 cannot parse. Migrate it to v2 first (no-op if
|
|
# already valid v2; backs up + validates + falls back to the shipped template).
|
|
CADDY="$SNAP/bin/caddy" bash "$SNAP/bin/migrate-caddyfile-v1-to-v2.sh" "$SNAP_COMMON/Caddyfile" || true
|
|
# #6552: as many open files as this service may have (see raise-nofile-limit).
|
|
source "$SNAP/bin/raise-nofile-limit"
|
|
raise_nofile_limit
|
|
# Use Caddy 2 command format
|
|
# The 'host' option is no longer needed in Caddy 2
|
|
# The 'agree' option is no longer needed as Caddy 2 doesn't prompt for EULA
|
|
env LC_ALL=C caddy run --config $SNAP_COMMON/Caddyfile
|
|
else
|
|
echo "caddy is disabled. Service stopping disabled"
|
|
# snapctl stop --disable ${SNAP_NAME}.caddy
|
|
# sleep here, in case snapctl fails to stop service so we do not restart too often
|
|
fi
|