Commit 40ccf45c authored by Keith Jolley's avatar Keith Jolley

Started development of offline job manager

parent f4aa2829
Version 1.1 introduces an offline job manager. This is required to control
analyses that take a long time for which it is inappropriate to require the
browser remains connected. When upgrading to version 1.1, you will need to
do the following:
1) Create new bigsdb_jobs database using jobs.sql found in the sql directory
2) Create new bigsdb UNIX user, e.g.
sudo useradd -s /bin/sh bigsdb
3) Create new bigsdb Postgres user, e.g.
as postgres
createuser bigsdb (no need to set specific roles)
4) Create empty bigsdb_jobs.log file in the /var/log directory, make this owned
by bigsdb, e.g.
sudo touch /var/log/bigsdb_jobs.log
sudo chown bigsdb:bigsdb /var/log/bigsdb_jobs.log
5) Copy the job_logging.conf file from the conf directory to /etc/bigsdb.
6) Update the /etc/bigsdb/bigsdb.conf file with the following (top section):
jobs_db=bigsdb_jobs
\ No newline at end of file
......@@ -25,7 +25,7 @@ use version; our $VERSION = qv('1.0.1');
use constant {
CONFIG_DIR => '/etc/bigsdb',
LIB_DIR => '/usr/local/lib',
DBASE_CONFIG_DIR => '/etc/bigsdb/dbases',
DBASE_CONFIG_DIR => '/etc/bigsdb/dbases'
};
#######End Local configuration################################
use CGI;
......
#!/usr/bin/perl -T
#Offline Job Manager for BIGSdb
#Written by Keith Jolley
#Copyright (c) 2011, University of Oxford
#E-mail: keith.jolley@zoo.ox.ac.uk
#
#This file is part of Bacterial Isolate Genome Sequence Database (BIGSdb).
#
#BIGSdb is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#BIGSdb is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with BIGSdb. If not, see <http://www.gnu.org/licenses/>.
package BIGSdb::main;
use strict;
###########Local configuration################################
use constant {
CONFIG_DIR => '/etc/bigsdb',
LIB_DIR => '/usr/local/lib',
DBASE_CONFIG_DIR => '/etc/bigsdb/dbases',
HOST => 'localhost',
PORT => 5432,
USER => 'bigsdb',
PASSWORD => 'bigsdb'
};
#######End Local configuration################################
use DBI;
use Log::Log4perl qw(get_logger);
use lib (LIB_DIR);
use BIGSdb::OfflineJobManager;
use BIGSdb::Dataconnector;
use BIGSdb::BIGSException;
Log::Log4perl->init_once( CONFIG_DIR . '/job_logging.conf' );
BIGSdb::OfflineJobManager->new( CONFIG_DIR, LIB_DIR, DBASE_CONFIG_DIR, HOST, PORT, USER, PASSWORD);
\ No newline at end of file
......@@ -6,11 +6,13 @@
#secure_tmp_dir: Location of web-inaccessible temporary directory
#prefs_db: Name of preference database
#auth_db: Name of authentication database
#jobs_db: Name of offline job queue database
tmp_dir=/home/httpd/pubmlst.org/tmp
secure_tmp_dir=/var/tmp
prefs_db=bigsdb_prefs
auth_db=bigsdb_auth
jobs_db=bigsdb_jobs
####EMBOSS####
#used for sequence alignment in allele query
......
#Change log levels for different modules below
#DEBUG: Useful for debugging.
#INFO: Informative messages, e.g. file and directory opens.
#WARN: Configuration inconsistency, application can continue to function.
#ERROR: Something wrong, can continue running, but may perform unexpectedly.
#FATAL: The application is about to terminate abnormally.
log4perl.logger.BIGSdb.Dataconnector=WARN, A1
log4perl.logger.BIGSdb.Datastore=WARN, A1
log4perl.logger.BIGSdb.Application_Benchmark=WARN, A1
log4perl.logger.BIGSdb.Application_Initiate=WARN, A1
log4perl.logger.BIGSdb.Application_Authentication=WARN, A1
log4perl.logger.BIGSdb.Prefs=WARN, A1
log4perl.logger.BIGSdb.Locus=WARN, A1
log4perl.logger.BIGSdb.Scheme=WARN, A1
log4perl.logger.BIGSdb.ClientDB=WARN, A1
log4perl.logger.BIGSdb.Page=WARN, A1
log4perl.logger.BIGSdb.Plugins=WARN, A1
log4perl.logger.BIGSdb.Charts=WARN, A1
log4perl.appender.A1=Log::Dispatch::File
log4perl.appender.A1.filename=/var/log/bigsdb_jobs.log
log4perl.appender.A1.mode=append
log4perl.appender.A1.layout=Log::Log4perl::Layout::PatternLayout
log4perl.appender.A1.layout.ConversionPattern=%d [%p] %F{1}:%L - %m%n
\ No newline at end of file
......@@ -209,7 +209,7 @@ sub _read_config_file {
my $config = Config::Tiny->new();
$config = Config::Tiny->read("$config_dir/bigsdb.conf");
foreach (
qw ( prefs_db auth_db emboss_path tmp_dir secure_tmp_dir blast_path muscle_path mogrify_path
qw ( prefs_db auth_db jobs_db emboss_path tmp_dir secure_tmp_dir blast_path muscle_path mogrify_path
reference refdb chartdirector)
)
{
......
#Written by Keith Jolley
#(c) 2011, University of Oxford
#E-mail: keith.jolley@zoo.ox.ac.uk
#
#This file is part of Bacterial Isolate Genome Sequence Database (BIGSdb).
#
#BIGSdb is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#BIGSdb is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with BIGSdb. If not, see <http://www.gnu.org/licenses/>.
package BIGSdb::OfflineJobManager;
use base qw(BIGSdb::Application);
use Error qw(:try);
use Log::Log4perl qw(get_logger);
sub new {
my ( $class, $config_dir, $plugin_dir, $dbase_config_dir, $host, $port, $user, $password ) = @_;
my $self = {};
$self->{'system'} = {};
$self->{'host'} = $host;
$self->{'port'} = $port;
$self->{'user'} = $user;
$self->{'password'} = $password;
$self->{'xmlHandler'} = undef;
$self->{'dataConnector'} = new BIGSdb::Dataconnector;
bless( $self, $class );
$self->_initiate( $config_dir, $dbase_config_dir );
# $self->{'dataConnector'}->initiate($self->{'system'});
$self->_db_connect;
}
sub _initiate {
my ( $self, $config_dir, $dbase_config_dir ) = @_;
$self->_read_config_file($config_dir);
my $logger = get_logger('BIGSdb.Application_Initiate');
# $logger->error("Test logging");
}
sub _db_connect {
my ($self) = @_;
my $logger = get_logger('BIGSdb.Application_Initiate');
if (!$self->{'config'}->{'jobs_db'}){
$logger->fatal("jobs_db not set in config file.");
return;
}
my %att = (
'dbase_name' => $self->{'config'}->{'jobs_db'},
'host' => $self->{'host'},
'port' => $self->{'port'},
'user' => $self->{'user'},
'password' => $self->{'password'},
'writable' => 1
);
try {
$self->{'db'} = $self->{'dataConnector'}->get_connection( \%att );
}
catch BIGSdb::DatabaseConnectionException with {
my $logger = get_logger('BIGSdb.Application_Initiate');
$logger->error("Can not connect to database '$self->{'config'}->{'jobs_db'}'");
return;
};
}
1;
\ No newline at end of file
CREATE TABLE jobs (
id text NOT NULL,
dbase_config text NOT NULL,
username text,
email text,
ip_address text NOT NULL,
submit_time timestamp NOT NULL,
start_time timestamp NOT NULL,
stop_time timestamp NOT NULL,
module text NOT NULL,
function text NOT NULL,
query text,
parameters text,
status text NOT NULL,
priority int NOT NULL,
PRIMARY KEY(id)
);
GRANT SELECT,UPDATE,INSERT,DELETE ON jobs TO apache,bigsdb;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment