Commit ae08fdcd authored by Adam Malone's avatar Adam Malone Committed by beejeebus
Browse files

#1546284: Check nodejs status via admin/reports/status

parent 50e79ca0
Loading
Loading
Loading
Loading
+40 −0
Changes for nodejs.install: 40 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -47,3 +47,43 @@ function nodejs_schema() {
  );
}

/**
 * Implements hook_requirements()
 */
function nodejs_requirements($phase) {
  if ($phase == 'runtime') {

    $result = array();
    $requirements['nodejs'] = array(
      'title' => t('Node.js'),
      'description' => t('Can Drupal connect to the Node.js server?'),
    );

    // Initiate a call to the Nodejs server
    // and react to the response.
    $message = new StdClass;
    $response = Nodejs::sendMessage($message);

    // drupal_http_request does the work for us so we just check to see
    // if it is an error or not and report back
    // $response->error: If an error occurred, the error message. Otherwise not set. 
    if (isset($response->error)) {
      $result = array(
        'value' => check_plain($response->error),
        'severity' => REQUIREMENT_ERROR,
      );
    }
    else {
      $result = array(
        'value' => check_plain($response->status_message),
        'severity' => REQUIREMENT_OK,
      );
    }

    // Merge the result from Nodejs
    $requirements['nodejs'] += $result;

  return $requirements;
  }
}
+2 −0
Changes for nodejs.module: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -672,6 +672,8 @@ class Nodejs {
      'method' => 'POST',
      'data' => drupal_json_encode($message),
      'headers' => self::$headers,
      // This is server to server, so start with a low default timeout.
      'timeout' => !empty(self::$config['timeout']) ? self::$config['timeout'] : 5,
    );
    return drupal_http_request(self::$baseUrl . 'nodejs/publish', $options);
  }