-
Notifications
You must be signed in to change notification settings - Fork 0
Deploy
In this documentation we're going to show three ways to deploy/turn available the generated results from report_html_db.pl. See by yourself the options and choose which one is more conviniet for your case.
- Lightweight mode - use this mode when you want to run locally, see how it works, and execte some tests. Please, always after run, make your own tests and see if everything is right.
- Apache - use this mode when you want to have a real service to share, log control, and you have a minimal notion about what the hell are you doing.
- Docker - use this mode when you don't want to lose some time installing all dependences
If you move the applications to another server, you'll need to set the filepath from SQLite database.db in Organism-Website/lib/Organism/Website/Model/Basic.pm.
__PACKAGE__->config(
schema_class => 'Organism::Website::Basic',
connect_info => {
# Add in next line filepath for database.db
dsn => 'dbi:SQLite:/var/www/organism/Organism-Website/database.db',
user => '',
password => '',
on_connect_do => q{PRAGMA foreign_keys = ON;PRAGMA encoding='UTF-8'},
}
);If you want to change connection with database you'll need to access Organism-Services/lib/Organism/Services/Model/SearchDatabaseRepository.pm and change:
__PACKAGE__->config(
dsn => "dbi:Pg:dbname=databaseName;host=address",
user => "username",
password => "password",
options => {},
);Remember, you have to change access permission in database configuration!
If you want to set REST endpoint variable which will be used by Website application, you'll need to change Organism-Website/organism_website.conf:
rest_endpoint http://127.0.0.1/organism_servicesBoth application results have been developed using Catalyst Web Framework, the framework provides the possibility to run a local server script, you can run both of them with the following commands:
./Organism-Services/script/organism_services_server.pl -p3000 -r &
./Organism-Website/script/organism_website_server.pl -p80 -r &You'll be able to access website in http://localhost and you can access services endpoint in http://localhost:3000.
You'll need to install some dependences:
sudo apt install apache2 libapache2-mod-perl2
cpan Catalyst::Engine::ApacheIf everything is right, you can active perl module for apache2:
sudo a2enmod perlApache by default have a configuration file for websites available in /etc/apache2/sites-available/000-default.conf, if you don't have created any service before, you can use this config file.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all
</Directory>
PerlOptions +Parent
PerlSwitches -I/usr/local/lib/x86_64-linux-gnu/perl/5.22.1 -I/usr/local/share/perl/5.22.1 -I/usr/lib/x86_64-linux-gnu/perl/5.22 -I/ONE/FILEPATH/ABOVE/Report_HTML_DB/ -I/usr/local/genome/egene2/bin -I/var/www/organism/Organism-Services/lib -I/var/www/organism/Organism-Website/lib
<Location /organism_services>
SetHandler modperl
PerlResponseHandler Organism::Services
</Location>
<Location /organism>
SetHandler modperl
PerlResponseHandler Organism::Website
</Location>
Alias /assets /var/www/organism/Organism-Website/root/assets
<Directory /var/www/organism/Organism-Website/root/assets>
Require all granted
Options FollowSymLinks
</Directory>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Be carefully with PerlSwitches parameter, you should pass define to apache2 the perl libraries paths using -I before every path, EVERY PERL LIBRARY THAT ISN'T RELATED TO THE PROJECT AND YOU WANT TO USE, SHOULD BE PASSED BEFORE THE LIBRARIES APPLICATION PATH!. I spend some fucking couple hours discovering about this.
If you see carefully, you'll need to set minimally the filepath which Report_HTML_DB is, the filepaths for lib applications to be runned. Here <Location /organism_services> you can set URL path to access service or website, change it. You'll need to change this to: PerlResponseHandler Organism::Services change Organism by your organism first name. Finally there is an Alias we created to set a URL to access assets filepath by Website application, if you add more applications from report_html_db.pl you should add the assets file of the new project to the directory defined.
Now, see considerations and execute the following commands to finnaly turn this shit available:
#activate perl lib apache
sudo a2enmod perl
#activate site configuration
sudo a2ensite 000-default
#restart apache service
sudo /etc/init.d/apache2 restartIf you don't have docker installed, here is a documentation. Choose your platform and follow instructions, they're very well explained.
You have two options to run the project:
- Use the image
wendelhime/platypus:latestand create a container with a shared volume composed by the filepath to the application result; - Use the image
wendelhime/platypus:websiteorwendelhime/platypus:servicesin adocker-compose.ymlfile and create a docker service, in this way, you can create more replicas of containers, limit process capacity, memory consume.
The docker image wendelhime/platypus:latest have by default a auxiliar script, if you run the following command, you'll have the help message:
docker run --rm wendelhime/platypus:latest
usage: auxiliar.py [-h] [--restendpoint RESTENDPOINT] [--dbname DBNAME]
[--dbhost DBHOST] [--dbusername DBUSERNAME]
[--dbpassword DBPASSWORD]
organism {website,service}
This is a auxiliar script responsible to run result applications from
report_html_db.pl in Docker.
positional arguments:
organism Organism first name
{website,service} Application type to be runned
port Port used to access application
optional arguments:
-h, --help show this help message and exit
--restendpoint RESTENDPOINT
Services REST endpoint URL, if you're running website,
this is required
--dbname DBNAME Database name
--dbhost DBHOST Database host URL
--dbusername DBUSERNAME
Database username
--dbpassword DBPASSWORD
Database passwordExecute the following command to run services application:
docker run \
-v /your/filepath/to/Organism-Services:/Organism-Services \
--net=host \
--rm \
--name Organism-Website \
wendelhime/platypus:latest Organism service 80 --dbname organism_db --dbhost 127.0.0.1 --dbusername username --dbpassword passwordYou need to share the filepath of the projects with the container, you can use the docker parameter -v /var/www/Organism-Services:/Organism-Services. After the image name, you should pass the script parameters. The script follow considerations section and autommatically apply changes.
Execute the following command to run website application:
docker run \
-v /your/filepath/to/Organism-Website:/Organism-Website \
--net=host \
-it \
--rm \
wendelhime/platypus:latest Curtobacterium website 3000 --restendpoint http://127.0.0.1:80 First of all download the docker-compose file, you'll need to change volume parameter, and if you want, access port. Before execute, you need to set variables of organism and finally execute the command:
ORGANISM=Curtobacterium TYPE=service DBNAME=curtobacterium_db DBUSERNAME=username DBPASSWORD=password docker stack deploy -c docker-compose.yml platypus-services
You can access services log with:
docker service logs -f platypus-services_webYou can use this docker-compose file to execute website project, you'll need to change volume parameter also, ports, and set variables before execute:
ORGANISM=Curtobacterium TYPE=website RESTENDPOINT=http://localhost docker stack deploy -c docker-compose.yml platypus-websiteYou can access website log with:
docker service logs -f platypus-website_web-
Getting started
1.1 Setup
1.2 Running
- Configuration files
2.1 Creating config file
2.2 Creating JSON file for Website pages
-
Developers Documentation
3.1 Services API
3.2 Website
3.3 Report_HTML_DB -
Deploy
4.1 Considerations
4.2 Apache
4.3 Docker
-
Questions and feedback