Terrible one-liner to make this easier to remember;
for i in $(varnishadm vcl.list | grep cold | awk '{print $4}') ; do varnishadm "vcl.discard $i" ; done
Terrible one-liner to make this easier to remember;
for i in $(varnishadm vcl.list | grep cold | awk '{print $4}') ; do varnishadm "vcl.discard $i" ; done
In a fit of desperation, I tweeted asking for *simple*, *easy*, cheap recipes. This is what I got in return. I’m totally posting this so it’s really easy to print them.
Shamelessly stolen from wikipedia because they’re thinking about removing this, as “Wikipedia is not a howto”. *sigh*.
With kernel version 3.5 and over, as well as kernel version 2.6.32-303 and over, it is likely better to use 1 for cases where 0 used to be optimal.
To temporarily set the swappiness in Linux, write the desired value (e.g. 10) to /proc/sys/vm/swappiness using the following command, running as root user:
# Set the swappiness value as root echo 10 > /proc/sys/vm/swappiness # Alternatively, run this sysctl -w vm.swappiness=10 # Verify the change cat /proc/sys/vm/swappiness 10 # Alternatively, verify the change sysctl vm.swappiness vm.swappiness = 10
Permanent changes are made in /etc/sysctl.conf via the following configuration line (inserted, if not present):
vm.swappiness = 10
10 is generally good for ‘I don’t want swapping to happen except if you *really* need it.
Are you getting a weird error from varnish that you’re having trouble working out? Is it cryptically saying that there’s an issue with your host definition in your VCL?
Expected ID got ';' (program line 165), at ('input' Line 20 Pos 30) .first_byte_timeout = 120; -----------------------------#
You need to add a time unit to your timeout definitions — ‘s’ for seconds, ‘m’ for minutes. Stupid cryptic error is dumbly cryptic. Grrr.
https://varnish-cache.org/lists/pipermail/varnish-bugs/2011-August/003983.html
So, you have a Varnish server running systemd, which is behind a reverse proxy for SSL like nginx, and you can’t work out how to make varnishncsa log IP addresses from a specified header? Well, it’s a bit of a pain in the neck really. You need to override the systemd service file, which is like systemd’s version of the init scripts. Due to it being systemd, this is not just a case of editing a file…
For Debian, you can use the service file below, and paste it into
/etc/systemd/system/varnishncsa.service
Once done, you need to reload systemd’s service listing itself;
$ systemctl daemon-reload
Congratulations, you now have varnishncsa logs including the visitor’s real IP address, as specified by Nginx. Change the name in “{X-Forwarded-For}” to change the header name, for example if you want CloudFlare’s view of the client’s IP address, use “CF-Connecting-IP”
[Service] RuntimeDirectory=varnishncsa Type=forking PIDFile=/run/varnishncsa/varnishncsa.pid User=varnishlog Group=varnish ExecStart=/usr/bin/varnishncsa -a -w /var/log/varnish/varnishncsa.log -D -P /run/varnishncsa/varnishncsa.pid -F '%%{X-Forwarded-For}i %%l %%u %%t "%%r" %%s %%b "%%{Referer}i" "%%{User-agent}i"' ExecReload=/bin/kill -HUP $MAINPID
If SystemD MariaDB/MySQL is failing to start, make sure your logs directory is set correctly. Sometimes this is caused by failing to correctly make sure the directory is moved.
You’ll see an error log in the journal as follows;
Nov 27 18:24:55 db-a mysqld[28677]: 2017-11-27 18:24:55 140273229838208 [Note] /usr/sbin/mysqld (mysqld 10.2.10-MariaDB-10.2.10+maria~jessie-log) starting as process 28677
Nov 27 18:24:55 db-a systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Nov 27 18:24:55 db-a systemd[1]: Failed to start MariaDB database server.
Nov 27 18:24:55 db-a systemd[1]: Unit mariadb.service entered failed state.
This is complicated, but I need to remember this, so I want to put it somewhere. You need to add this to apache config / .htaccess file to get apache to correctly set the HTTPS environment variable when the backend is secure. It trips based on the X-Forwarded-Proto header being ‘https’.
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
For some reason, grep, thought that a “HTML document, Non-ISO extended-ASCII text, with very long lines” was a binary, so refused to print contents.
TIL about -a. In grep, -a tells grep to process a binary file as if it were text. This means, if grep incorrectly thinks a file is binary, it’ll still work with it.
That cost me at least 2 hours of scratching my head, wondering why my regex wasn’t working as it should…
If you get an error like:
Fatal error: Call to a member function select() on a non-object in /home/username/public_html/app/code/community/Fishpig/Wordpress/Model/Resource/Page.php on line 119
Then, check you’ve not just changed a MySQL username, without updating the fishpig configuration, or otherwise Fishpig can’t access the MySQL database for some reason. It seems to store a MySQL login in Magento config. I’ve not yet found exactly where, I’ll update this post with more once I understand more about what it’s doing.
It presented as the main Magento site throwing the following error:
exception ‘Zend_Exception’ with message ‘dbModel read resource does not implement Zend_Db_Adapter_Abstract’
Which it seems that most everyone will tell you to clear your cache to fix. You *will* need to clear your cache, probably. Just, after fixing the MySQL connection issue.
The following line is to make it easier for people googling to find this post:
Fatal error: Call to a member function select() on a non-object in /public_html/app/code/community/Fishpig/Wordpress/Model/Resource/Page.php on line 119 magento fishpig
This post my making sure https://xkcd.com/979/ doesn’t happen from me.
One of my bosses sent me this, his favourite easy recipe for a nice hot chocolate style drink. Saving it here so I remember to do it..
Half a tin of coconut milk in a saucepan.
Simmer.
Stir in as much cocoa as you want, and chunks of chocolate too, if you like it thick.
Add some xylitol to sweeten.
Pour into a mug.
Thick, astonishingly satisfying and good for you.
(Obviously, only pour into a mug once all the cocoa has mixed and chocolate melted – I use a whisk, and add a capful of vanilla essence too).