понеділок, 11 березня 2013 р.

Using wget/curl to connect to specific server/vhost

One of DNS advantages is it's round-robin capability. But often you need to connect to specific server to specific vhost.

wget is capable of performing this task, just use --header switch:

wget http://2.2.2.2/the_url_to_test/ --header 'Host: www.example.com'
curl also can ;-)
curl --verbose --header 'Host: www.example.com''http://2.2.2.2/the_url_to_test'
Very handy features for shell programming!

References:
http://lists.gnu.org/archive/html/bug-wget/2011-03/msg00040.html
http://drewish.com/content/2010/03/using_curl_and_the_host_header_to_bypass_a_load_balancer

четвер, 7 березня 2013 р.

MySQL in scripting - using timeouts

If you are using any cron jobs with which connect to MySQL and do some work it will be wise decision to think about what will happen when MySQL daemon stops. I'll tell you! Your scripts will not be able to connect to database. And they will run until database returns.  They may run forever!
Just look into man of mysqld.

      ·   connect_timeout
           The number of seconds before connection timeout. (Default value is
           0.)
See that?! Default value is 0 - it means infinity!
No need to have such risk.
Hence quickly add the following parameter to your scripts (example below use 5 seconds timeout):
--connect_timeout=5