You are here

function _varnish_execute_command in Varnish 7

Same name and namespace in other branches
  1. 8 varnish.module \_varnish_execute_command()
  2. 6 varnish.module \_varnish_execute_command()

Send command to varnish.

1 call to _varnish_execute_command()
_varnish_terminal_run in ./varnish.module
Helper function that sends commands to Varnish.

File

./varnish.module, line 393
Common functions used for the module.

Code

function _varnish_execute_command($client, $command) {

  // Send command and get response.
  $result = socket_write($client, "{$command}\n");
  $status = _varnish_read_socket($client);
  if ($status['code'] != 200) {
    watchdog('varnish', 'Received status code @code running %command. Full response text: @error', array(
      '@code' => $status['code'],
      '%command' => $command,
      '@error' => $status['msg'],
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  else {

    // Successful connection.
    return $status;
  }
}