You are here

function varnish_requirements in Varnish 5

Same name and namespace in other branches
  1. 8 varnish.install \varnish_requirements()
  2. 6 varnish.module \varnish_requirements()
  3. 7 varnish.install \varnish_requirements()

Implementation of hook_requirements()

Insure that varnish's connection is good.

File

./varnish.module, line 60
varnish.module Provide drupal hooks for integration with the Varnish control layer.

Code

function varnish_requirements($phase) {
  if ($phase == 'runtime') {
    $requirements = array(
      'varnish',
    );
    $requirements['varnish']['title'] = t('Varnish status');

    // try a varnish admin connect, report results
    $status = _varnish_terminal_run('status', 300);
    if (strpos($status, 'Child in state running') === FALSE) {
      $requirements['varnish']['value'] = t('Varnish connection broken');
      $requirements['varnish']['severity'] = REQUIREMENT_ERROR;
      $requirements['varnish']['description'] = t('The Varnish control terminal is not responding at %server on port %port.', array(
        '%server' => variable_get('varnish_control_terminal_server', '127.0.0.1'),
        '%port' => variable_get('varnish_control_terminal_port', '6082'),
      ));
    }
    else {
      $requirements['varnish']['value'] = t('Varnish running. Observe more detailed statistics !link.', array(
        '!link' => l(t('here'), 'admin/reports/varnish'),
      ));
    }
    return $requirements;
  }
}