BatchConnect

Library used to generate batch scripts that start up web servers, VNC servers,
and etc., through batch jobs running on HPC resources. It is also used to
generate connection information from these batch jobs so that a user can
connect to their batch job server.

Installation

Add this line to your application's Gemfile:

gem'batch_connect'

And then execute:

$ bundle

Or install it yourself as:

$ gem install batch_connect

Usage

A simple batch script can be generated as such:

require'batch_connect'# Generate batch script object
my_script=BatchConnect::Script.new# Render the script and output it to a file
File.open("/path/to/my/batch_script.sh",'w'){|f|f.write(my_script.render)}

This generates a batch script with no PBS directives written in Bash at:

/path/to/my/batch_script.sh

You can take a quick look at it:

$ cd /path/to/...
$ cat batch_script.sh

Notice it calls within the script the following scripts: before.sh,
script.sh, after.sh, and clean.sh. These should all be located in the
current working directory of the batch script during the batch job submission.

file

description

before.sh

this file is sourced before the main script is called so you can do any pre-processing such as setting connection information variables

after.sh

this file is sourced after the main script is called so you can do any post-processing such as setting connection information variables

clean.sh

this file is sourced during an exit of the batch script used to clean up anything the main script may leave behind

script.sh

this is the main script that starts and controls the web server of your choice

You will need to set the connection information required for users to connect
to this server:

Wait until the job is started. When it is running take a look at the yaml file
that is generated:

$ cat 123456.yml
host: 'node0001.hpc.edu'
port: '6584'

This is the yaml file that we will parse to get connection information for the
user to connect to our server. Lets do a simple SSH tunnel connection to our
new server:

require'batch_connect'# Create a connection view for this server
my_conn=BatchConnect::Connection.new(yml:"/path/to/123456.yml")# Render this view object for a terminal making an SSH tunnel. We do need to
# give it some help though.
my_conn.render(:terminal,{local_port:1234,ssh_user:"my_username",ssh_host:"login.hpc.edu"})#=> "ssh -L 1234:node0001.hpc.edu:6584 [email protected]\n"

This generates a batch script with no PBS directives written in Bash at:

/path/to/my/batch_script.sh

You should not need to create before.sh, after.sh, or clean.sh. But you
will need to create the main script script.sh. This script is called within
the VNC session itself, so this is where you launch your GUI applications.

Let's create a script that starts up a Gnome desktop for RHEL6, so modify
script.sh as such: