Skip to content
Browse files

start to add framework for command-line addition of slaves

  • Loading branch information...
1 parent 1a3e5c1 commit 57eeb623d1c65991ef96e955014f95f38bffc3cb @lstein lstein committed
Showing with 75 additions and 0 deletions.
  1. +66 −0 bin/gbrowse_add_slaves.pl
  2. +3 −0 conf/GBrowse.conf
  3. +6 −0 conf/renderfarm.conf
View
66 bin/gbrowse_add_slaves.pl
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+
+use strict;
+use Bio::Graphics::Browser2;
+use File::Spec;
+use Text::ParseWords 'shellwords';
+use Getopt::Long;
+
+my (@to_add,@to_remove,@to_set);
+
+GetOptions(
+ 'add=s' => \@to_add,
+ 'remove=s' => \@to_remove,
+ 'set=s' => \@to_set
+ ) or die <<USAGE;
+Usage: gbrowse_update_renderers.pl [--options]
+
+Options:
+
+ --add Add server to list of renderers.
+ --remove Remove server from list of renderers.
+ --set Set renderer list to the given set.
+
+Each option can be specified multiple times:
+
+ gbrowse_update_renderers.pl --add http://coyote.acme.com:8081 \
+ --add http://roadrunner.acme.com:8081
+
+USAGE
+ ;
+if (@ARGV && !@to_add && !@to_remove) {
+ push @to_set,@ARGV;
+}
+
+my $globals = Bio::Graphics::Browser2->open_globals;
+my $render_conf = File::Spec->catfile($globals->config_base,'renderfarm.conf');
+-e $render_conf or system 'touch',$render_conf;
+my $conf = Bio::Graphics::FeatureFile->new(-file=>$render_conf) or die "Couldn't open $render_conf: $!";
+my $use_renderfarm = $conf->setting(general=>'renderfarm');
+my @remote_renderers = shellwords($conf->setting(general=>'remote renderer'));
+my %remote_renderers = map {$_=>1} @remote_renderers;
+
+for my $add (@to_add) {
+ $remote_renderers{$add}++;
+}
+for my $sub (@to_remove) {
+ delete $remote_renderers{$sub};
+}
+if (@to_set) {
+ %remote_renderers = map {$_=>1} @to_set;
+}
+
+# write out
+$use_renderfarm = keys %remote_renderers > 0 ? 1 : 0;
+
+open my $f,'>',"$render_conf.new" or die "Couldn't open $conf.new: $!";
+print $f "[GENERAl]\n";
+print $f "renderfarm = $use_renderfarm\n";
+print $f "remote renderer = \n";
+for my $s (keys %remote_renderers) {
+ print $f "\t",$s,"\n" or die "Couldn't write: $!";
+}
+close $f or die "Couldn't write: $!";
+rename "$render_conf.new",$render_conf;
+
+exit 0;
View
3 conf/GBrowse.conf
@@ -84,6 +84,9 @@ expire session = 1M # expire unused sessions after a month
expire cache = 2h # expire cached data if unmodified for >2 hours
expire uploads = 6w # expire uploaded data if unused for >6 weeks
+# Renderfarm
+#include renderfarm.conf
+
# Appearance settings
truecolor = 1 # better appearance at the expense of larger image files
View
6 conf/renderfarm.conf
@@ -0,0 +1,6 @@
+renderfarm = 0
+
+remote renderer =
+ http://localhost:8101
+ http://localhost:8102
+ http://localhost:8103

0 comments on commit 57eeb62

Please sign in to comment.
Something went wrong with that request. Please try again.