Created
June 7, 2025 15:25
-
-
Save eksiscloud/b32ab552ad4513210a79f5c5d138a018 to your computer and use it in GitHub Desktop.
Varnish is more faster when working directory is in tmpfs. And 7.6 started nagging if not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Varnish working directory location in tmpfs | |
TMPFS_DIR="/dev/shm/varnish" | |
echo "Creating directory: $TMPFS_DIR" | |
mkdir -p "$TMPFS_DIR" | |
chown -R varnish:varnish "$TMPFS_DIR" | |
# Path to override.conf | |
OVERRIDE_DIR="/etc/systemd/system/varnish.service.d" | |
OVERRIDE_FILE="$OVERRIDE_DIR/override.conf" | |
## Heads up! Change this to match your setup | |
echo "Writing systemd override: $OVERRIDE_FILE" | |
mkdir -p "$OVERRIDE_DIR" | |
cat > "$OVERRIDE_FILE" <<EOF | |
[Service] | |
ExecStart= | |
ExecStart=/usr/sbin/varnishd \\ | |
-I /etc/varnish/start.cli \\ | |
-P /var/run/varnish.pid \\ | |
-j unix,user=vcache \\ | |
-F \\ | |
-a :8080 \\ | |
-T localhost:6082 \\ | |
-f "" \\ | |
-S /etc/varnish/secret \\ | |
-p vsl_mask=+Hash \\ | |
-n $TMPFS_DIR \\ | |
-s malloc,5G | |
EOF | |
echo "Reloading systemd" | |
systemctl daemon-reexec | |
systemctl daemon-reload | |
echo "Restarting Varnish" | |
systemctl restart varnish | |
echo "Ready! Working directory is now in tmpfs: $TMPFS_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment