dictyBase Developers

Solving one problem at a time

Running PSGI Gbrowse2

Preamble

  • Skip this section if you just want to go ahead with installation.
  • Read either of PSGI readme or the blog post.
  • The steps below are essentially a modified version of the installation routine described above.
  • Perlbrew is used for managing perl without root privileges and system perl is left alone.
  • Perlbrew’s local lib feature is used for managing dependencies.
  • cpanm is used for installing dependencies.
  • For deployment purposes modules are installed without running the unit tests(cpanm -n)

Perl environment

1
curl -kL http://install.perlbrew.pl | bash
  • Then setup your bash environment as instructed by perlbrew. Typically that will be in your .bashrc
1
source ~/perl5/perlbrew/etc/bashrc
  • For custom installation of perlbrew set the PERLBREW_HOME environmental variable. For example if it needs to be installed in a shared folder such as /home/gbrowse
1
2
3
4
5
export PERLBREW_ROOT=/home/gbrowse
curl -kL http://install.perlbrew.pl | bash
In the .bashrc
export PERLBREW_ROOT=/home/gbrowse
source ${PERLBREW_ROOT}/etc/bashrc
  • Install perl
1
perlbrew install  perl-5.10.1

Alternatively, with some compile time options in a 64bit CentOs 6 system

1
2
3
perlbrew install perl-5.10.1 -j 4  -Duse64bitall  -Duselargefiles \ 
                -Aldflags='-L/lib64 -L/usr/lib64' -Dcc=g
perlbrew switch perl-5.10.1
  • Install cpanm and some helper modules
1
2
perlbrew install-cpanm
cpanm -n App::pmuninstall App::cpanoutdated
  • Create a standalone local lib for installing dependencies. Use a separate local lib for every version of gbrowse2
1
2
3
 perlbrew lib create gbrowse-2.40
 perlbrew use lib perl-5.10.1@gbrowse-2.40 (perl version might vary)
 perlbrew switch lib perl-5.10.1@gbrowse-2.40 (make it permanent in the bash)
  • Checkout gbrowse2 from github and go to the develop branch
1
2
git clone git://github.com/dictyBase/GBrowse-PSGI.git
git checkout -b develop origin/develop
  • Install dependencies
  • gbrowse2 needs libgd2 to function. Looks here for installing in your OS. Instructions for debian,red hat based linuxes and MacOSX are given there. However, for a latest MacOSX with homebrew, you should do with brew install
1
HARNESS_OPTIONS=j4 cpanm -n --installdeps .

Setup gbrowse2

Most of the commands below are recommended to run from inside of gbrowse2 checkout folder

  • Set envrionmental variables. Vary the gbrowse version as needed.
1
2
3
4
5
export GBROWSE_ROOT=`pwd`/gbrowse
export GBROWSE_VERSION=2.40

The above will setup the folder where gbrowse2 html,js,
temporary files,sessions,images,config files etc will be kept.

Note: For CentOs with SELinux enabled install Term::ReadKey

1
cpanm Term::ReadKey
  • Configure gbrowse2 path. Run the command below from the gbrowse2 checkout folder.
1
2
3
4
5
6
7
8
perl Build.PL --conf $GBROWSE_ROOT/$GBROWSE_VERSION/conf \
             --htdocs $GBROWSE_ROOT/$GBROWSE_VERSION/html \
             --cgibin $GBROWSE_ROOT/$GBROWSE_VERSION/cgi \
             --tmp $GBROWSE_ROOT/$GBROWSE_VERSION/tmp \
             --persistent $GBROWSE_ROOT/$GBROWSE_VERSION/tmp/persistent  \
             --databases $GBROWSE_ROOT/databases \
             --installconf n --installetc n   \
             --wwwuser $LOGNAME
  • Install gbrowse2 libraries. Just press enter at the password prompt. Also answer ‘no[n]’ for apache2 restart.

Note: Again for CentOs with SELinux enabled, it will ask for sudo password. Just hit enter three times.

1
./Build install
  • Edit the configuration files. It is recommended to edit the configuration files in the installed folder rather than the stock one. It gives the flexibility of having separate config files for every version.
1
2
3
cd $GBROWSE_ROOT/$GBROWSE_VERSION
and edit the files
Make sure the paths in the yeast demo files are being set properly.
  • Run and test out gbrowse2 with plack
1
plackup $GBROWSE_ROOT/$GBROWSE_VERSION/conf/GBrowse.psgi

Deploy

Two modes of plack deployment have been tested, Starman as backend web server and standalone FCGI . Instructions are given for nginx however setting up with apache2 would be simple. * Install nginx using your OS package manager.

Nginx with Starman

  • Install and then start Starman
1
2
3
4
5
cpanm Starman
plackup -s Starman --port 9000 --daemonize --pid /tmp/starman_gb2.pid \
    $GBROWSE_ROOT/$GBROWSE_VERSION/conf/GBrowse.psgi

The above will have Starman running in background on port 9000
  • Open and edit the nginx.conf file. It will deploy it under /browser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## upstream block
upstream gb2 {
  server 127.0.0.1:9000
}

# backend server mapping
location /browser {
   proxy_read_timeout 300;
   rewrite /browser/(.*) /$1 break;
   proxy_pass http://gb2;
   proxy_set_header Host $host;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Forwarded-Host $host;
   proxy_set_header X-Real-IP $remote_addr;
}

# serving static files directly instead of going through Starman
# better for deployment
# For every gbrowse version path have to be changed 
location /gbrowse2 {
   alias /home/ubuntu/GBrowse-PSGI/gbrowse/2.40/html;
   expires 30d;
}
1
kill `cat /tmp/starman_gb2.pid`

Nginx with FCGI

Note: The gbrowse_img script do not work with this backend. It run only once and then gives no response.

  • Install and start standalone FCGI
1
2
3
 cpanm FCGI FCGI::ProcManager
 plackup -s FCGI --nproc 10 --listen /tmp/gbrowse.sock --pid /tmp/fcgi_gb2.pid --daemonize \
                       $GBROWSE_ROOT/$GBROWSE_VERSION/conf/GBrowse.psgi
  • Open and edit nginx.conf file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
location /browser {
     set $script "";
     set $path_info $uri;
     fastcgi_pass unix:/tmp/gbrowse.sock;
     fastcgi_param  SCRIPT_NAME      /browser;
     fastcgi_param  PATH_INFO        $path_info;
     fastcgi_param  QUERY_STRING     $query_string;
     fastcgi_param  REQUEST_METHOD   $request_method;
     fastcgi_param  CONTENT_TYPE     $content_type;
     fastcgi_param  CONTENT_LENGTH   $content_length;
     fastcgi_param  REQUEST_URI      $request_uri;
     fastcgi_param  SERVER_PROTOCOL  $server_protocol;
     fastcgi_param  REMOTE_ADDR      $remote_addr;
     fastcgi_param  REMOTE_PORT      $remote_port;
     fastcgi_param  SERVER_ADDR      $server_addr;
     fastcgi_param  SERVER_PORT      $server_port;
     fastcgi_param  SERVER_NAME      $server_name;
}

# serving static files directly instead of going through perl FCGI
# better for deployment
# For every gbrowse version path have to be changed 
location /gbrowse2 {
   alias /home/ubuntu/GBrowse-PSGI/gbrowse/2.40/html;
   expires 30d;
}
1
kill `cat /tmp/fcgi_gb2.pid`