Skip to content

Passenger Ruby Report App Tutorial

Eric Franz edited this page Sep 13, 2017 · 14 revisions

Passenger Ruby Status App Tutorial

**Note: this is a DRAFT of a tutorial that will be moved to **

Passenger Overview

TODO

Tutorial

Login to Open OnDemand, click "Develop" and "My Sandbox Apps (Development)". Click "New Product" and "Clone Existing App". We will be starting with an example status app that displays the output of the ps command.

screenshot

  1. Directory name: quota
  2. Git remote: https://github.com/OSC/ood-example-ps
  3. Check "Create new Git Project from this?"
  4. Click Submit

screenshot

Launch the app by clicking the large blue Launch button and in a new browser window/tab you will see the output of a ps command filtered using grep.

screeenshot

The features of this app include:

  1. The app uses the custom branded Bootstrap 3 that My Jobs ande ActiveJobs apps use.
  2. The navbar contains a link back to the dashboard.
  3. On a request, the app runs a shell command, parses the output, and displays the result in a table.

This serves as a good starting point for any status app to build for OnDemand, because

  1. the app has the branding matching other OnDemand apps
  2. all status apps will do something similar on a request to the app:
    1. get raw data from a shell command or http request
    2. parse the raw data into an intermediate object representation
    3. use that intermediate object representation to display the data formatted as a table or graph

Go back to the Dashboard browser window/tab where the quota details page is displayed. Click the Files button to open this app in the File Explorer. Notice the structure of the app:

  1. config.ru is the entry point for the app (as is for all Ruby Passenger apps)
  2. the Gemfile and Gemfile.lock specify the Ruby gem dependencies, and those dependencies are installed in vendor/bundle
  3. public/ contains static css and js files. everything under public/ is automatically served up by NGINX
  4. views/ contains index.html which is the template for the body of the index page, and the layout.html which contains the erb tag <%== yield %> that is replaced with the rendered contents of index.html

Ruby example

def foo
  "bar"
end
  • a regular expression that best describes all the hosts that you would want a user to connect to through the proxy (e.g., [\w.-]+\.osc\.edu)

  • confirm that if you run the command hostname from a compute node it will return a string that matches the above regular expression

    Ruby example:

    def foo
      "bar"
    end

    Yaml example:

    # /etc/ood/config/clusters.d/cluster1.yml
    ---
    v2:
      # ...
      # ... other configuration options ...
      # ...
      batch_connect:
        basic:
          # ...
          # set_host: "host=$(hostname)"
          set_host: "host=$(hostname -A | awk '{print $1}')"
        vnc:
          # ...
          # set_host: "host=$(hostname)"
          set_host: "host=$(hostname -A | awk '{print $1}')"

Numbered List Example

  1. We will update the Apache configuration file by adding Location directives that will be used for the reverse proxy. This requires modifying the configuration file for the :ref:`ood-portal-generator`.

    cd ~/ood/src/ood-portal-generator
  2. Something... Another thing.

  3. Re-build the Apache config:

https://raw.githubusercontent.com/OSC/ood-documentation/develop/source/images/active-jobs-diagram.png
Clone this wiki locally