#!/bin/sh # # # Varnish # # Description: Manage varnish instances as a HA resource # # Author: Léon Keijser # # License: GNU General Public License (GPL) # # See usage() for more details # # OCF instance parameters: # OCF_RESKEY_pid # OCF_RESKEY_binary # OCF_RESKEY_client_binary # OCF_RESKEY_config # OCF_RESKEY_name # OCF_RESKEY_listen_address # OCF_RESKEY_mgmt_address # OCF_RESKEY_ttl # OCF_RESKEY_varnish_user # OCF_RESKEY_varnish_group # OCF_RESKEY_backend_type # OCF_RESKEY_backend_size # OCF_RESKEY_backend_file # OCF_RESKEY_thread_pools # OCF_RESKEY_thread_pool_min # OCF_RESKEY_thread_pool_max # OCF_RESKEY_thread_pool_timeout # OCF_RESKEY_secret # ####################################################################### # Initialization: : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs ####################################################################### # Set default paramenter values # Set these two first, as other defaults depend on it OCF_RESKEY_name_default=${OCF_RESOURCE_INSTANCE} : ${OCF_RESKEY_name=${OCF_RESKEY_name_default}} OCF_RESKEY_config_default="" OCF_RESKEY_binary_default=varnishd OCF_RESKEY_client_binary_default=varnishadm OCF_RESKEY_pid_default=/var/run/varnishd_${OCF_RESKEY_name}.pid OCF_RESKEY_listen_address_default=0.0.0.0:80 OCF_RESKEY_ttl_default=600 OCF_RESKEY_varnish_user_default=varnish OCF_RESKEY_varnish_group_default=varnish OCF_RESKEY_backend_type_default=malloc OCF_RESKEY_backend_size_default=1G OCF_RESKEY_backend_file_default=/var/lib/varnish/${OCF_RESKEY_name}.bin OCF_RESKEY_thread_pools_default=2 OCF_RESKEY_thread_pool_min_default=100 OCF_RESKEY_thread_pool_max_default=3000 OCF_RESKEY_thread_pool_timeout_default=120 OCF_RESKEY_maxfiles_default=131072 OCF_RESKEY_max_locked_memory_default=82000 OCF_RESKEY_secret_default=/etc/varnish/secret : ${OCF_RESKEY_config=${OCF_RESKEY_config_default}} : ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}} : ${OCF_RESKEY_client_binary=${OCF_RESKEY_client_binary_default}} : ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}} : ${OCF_RESKEY_listen_address=${OCF_RESKEY_listen_address_default}} : ${OCF_RESKEY_ttl=${OCF_RESKEY_ttl_default}} : ${OCF_RESKEY_varnish_user=${OCF_RESKEY_varnish_user_default}} : ${OCF_RESKEY_varnish_group=${OCF_RESKEY_varnish_group_default}} : ${OCF_RESKEY_backend_type=${OCF_RESKEY_backend_type_default}} : ${OCF_RESKEY_backend_size=${OCF_RESKEY_backend_size_default}} : ${OCF_RESKEY_backend_file=${OCF_RESKEY_backend_file_default}} : ${OCF_RESKEY_thread_pools=${OCF_RESKEY_thread_pools_default}} : ${OCF_RESKEY_thread_pool_min=${OCF_RESKEY_thread_pool_min_default}} : ${OCF_RESKEY_thread_pool_max=${OCF_RESKEY_thread_pool_max_default}} : ${OCF_RESKEY_thread_pool_timeout=${OCF_RESKEY_thread_pool_timeout_default}} : ${OCF_RESKEY_maxfiles=${OCF_RESKEY_maxfiles_default}} : ${OCF_RESKEY_max_locked_memory=${OCF_RESKEY_max_locked_memory_default}} : ${OCF_RESKEY_secret=${OCF_RESKEY_secret_default}} meta_data() { cat < 1.0 The Varnish Resource Agent can manage several varnishd instances throughout the cluster. It does so by creating a unique PID file and requires a unique listen address and name for each instance. Manage a Varnish instance The VCL configuration file that Varnish should manage, for example "/etc/varnish/default.vcl". VCL file Override the name of the instance that should be given to Varnish (defaults to the resource identifier). Instance name Write the process's PID to the specified file. The default will include the specified name, i.e.: "/var/run/varnish_production.pid". Unlike what this help message shows, it is most likely not necessary to change this parameter. Listen address Listen on this address:port, for example "192.168.1.1:80" Listen address Provide a management interface, for example "127.0.0.1:2222" Management interface Specify a hard minimum time to live for cached documents. TTL Specify the name of an unprivileged user to which the child process should switch before it starts accepting connections. Unprivileged user Specify the name of an unprivileged group to which the child process should switch before it starts accepting connections. Unprivileged group Use the specified storage backend. Valid options are 'malloc' for memory and 'file' for a file backend. Backend type Specify the size of the backend. For example "1G". Backend size Specify the backend filename if you use backend_type file. For example /var/lib/varnish/mybackend.bin Backend file Number of worker thread pools. Each pool has the minimum, maximum and timeout values configured in the thread_pool_min, thread_pool_max and thread_pool_timeout parameters Worker thread pools Start at least min but no more than max worker threads with the specified idle timeout in each pool. Minimum worker threads Start at least min but no more than max worker threads with the specified idle timeout in each pool. Maximum worker threads Start at least min but no more than max worker threads with the specified idle timeout in each pool. Worker threads timeout This is used to control Varnish via a CLI. It's currently only used to check the status of the running child process. Varnish admin utility Maximum number of open files (for ulimit -n) Max open files Locked shared memory limit (for ulimit -l) Max locked memory Path to a file containing a secret used for authorizing access to the management port. Path of the secret file END } ####################################################################### varnish_usage() { cat <