[Bio] / FigKernelScripts / run_rabbit_daemon.pl Repository:
ViewVC logotype

View of /FigKernelScripts/run_rabbit_daemon.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Thu Oct 13 19:35:11 2011 UTC (8 years, 4 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_release_3_1_2, mgrast_dev_12152011, mgrast_dev_10262011
Changes since 1.2: +4 -3 lines
fix default vhost
add slow-server designation

use strict;
use Log::Log4perl;
use ServerThing;

=head1 NAME

run_rabbit_daemon - Run one of the RabbitMQ-based daemons. 

=head1 SYNOPSIS

run_rabbit_daemon [-h hostname] [-u username] [-p password] [-c config-file] class-name role

Command line options:

=head1 OPTIONS

=over 4

=item -h hostname

Hostname or IP address of the rabbit broker.

=item -u username

Username for the rabbit broker.

=item -p password

Password for the rabbit broker.

=item -c filename

Logging configuration file.

=item -f port

Listening port for the FCGI gateway.

=item class-name

Sapling object class to be served; currently either ANNO or SAP.

=item role

Role for this daemon. Either "server" or "fcgi-gw".

=item slow

If set, this server handles rpc_slow.* messages for fast/slow
server distinction. Currently (Oct 2011) used for annotation
server calls where -assignToAll is selected.

=back

=cut

my $rabbitmq_host = '192.5.200.30';
my $rabbitmq_user = 'guest';
my $rabbitmq_password = 'guest';
my $rabbitmq_vhost = '/';
my $log_conf;
my $fcgi_port = 8081;
my $is_slow_request_server = 0;

my %valid_class = map { $_ => 1 } qw(ANNO SAP);
my %valid_role = map { $_ => 1 } qw(server fcgi-gw);

use Getopt::Long;

my $rc = GetOptions("host=s" => \$rabbitmq_host,
		    "user=s" => \$rabbitmq_user,
		    "vhost=s" => \$rabbitmq_vhost,
		    "password=s" => \$rabbitmq_password,
		    "config=s" => \$log_conf,
		    "fcgi-port=i" => \$fcgi_port,
		    "slow" => \$is_slow_request_server,
		   );

(@ARGV == 2 and $rc) or die "Usage: run_rabbit_daemon [args] class-name role\n";

my $conf = {
    rabbitmq_host => $rabbitmq_host,
    rabbitmq_user => $rabbitmq_user,
    rabbitmq_vhost => $rabbitmq_vhost,
    rabbitmq_password => $rabbitmq_password,
    fcgi_port => $fcgi_port,
    slow_queue_listener => $is_slow_request_server,
};

if ($log_conf)
{
    Log::Log4perl->init($log_conf);
}

my $class = shift;
my $role = shift;

if (!$valid_class{$class})
{
    die "Invalid class $class";
}

if (!$valid_role{$role})
{
    die "Invalid role $role";
}

my $slow_str = $is_slow_request_server ? ":slow" : "";
if (defined(my $i = $ENV{DAEMON_INDEX}))
{
    $0 = "SERVER:$class:$role$slow_str ($i) $0";
}
else
{
    $0 = "SERVER:$class:$role$slow_str $0";
}
if ($role eq 'server')
{
    ServerThing::RunRabbitMQServer($class, $conf);
}
elsif ($role eq 'fcgi-gw')
{
    ServerThing::RunRabbitMQClientAsync($class, $conf);
}
else
{
    die "Unknown role $role";
}

sub error_log_filename 
{
    print "Getting error filename\n";
    return "/tmp/anno_server.log";
}

sub debug_log_filename 
{
    print "Getting error filename\n";
    return "/tmp/anno_server.debug.log";
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3