1 | #!/usr/bin/perl -w
|
---|
2 |
|
---|
3 | ###########################################################################
|
---|
4 | #
|
---|
5 | # run_solr_server.pl -- perl script that uses solrserver.pm to stop and
|
---|
6 | # start the jetty server included with the solr extension for Greenstone3.
|
---|
7 | # A component of the Greenstone digital library software
|
---|
8 | # from the New Zealand Digital Library Project at the
|
---|
9 | # University of Waikato, New Zealand.
|
---|
10 | #
|
---|
11 | # Copyright (C) 2012 New Zealand Digital Library Project
|
---|
12 | #
|
---|
13 | # This program is free software; you can redistribute it and/or modify
|
---|
14 | # it under the terms of the GNU General Public License as published by
|
---|
15 | # the Free Software Foundation; either version 2 of the License, or
|
---|
16 | # (at your option) any later version.
|
---|
17 | #
|
---|
18 | # This program is distributed in the hope that it will be useful,
|
---|
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
21 | # GNU General Public License for more details.
|
---|
22 | #
|
---|
23 | # You should have received a copy of the GNU General Public License
|
---|
24 | # along with this program; if not, write to the Free Software
|
---|
25 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
26 | #
|
---|
27 | ###########################################################################
|
---|
28 |
|
---|
29 | # For easily starting and stopping the jetty server (that is included with
|
---|
30 | # the solr extension for Greenstone 3) from the command-line.
|
---|
31 | # First source gs3-setup.sh, then this script can be run as follows:
|
---|
32 | # run_solr_server.pl start
|
---|
33 | # which runs the jetty server.
|
---|
34 | # To stop the jetty server, re-run the script with the stop parameter:
|
---|
35 | # run_solr_server.pl stop
|
---|
36 |
|
---|
37 |
|
---|
38 | BEGIN {
|
---|
39 | die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
|
---|
40 | die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
|
---|
41 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
|
---|
42 |
|
---|
43 | die "GEXT_SOLR not set\n" unless defined $ENV{'GEXT_SOLR'};
|
---|
44 | my $solr_ext = $ENV{'GEXT_SOLR'};
|
---|
45 | unshift (@INC, "$solr_ext/perllib");
|
---|
46 | }
|
---|
47 |
|
---|
48 | use strict;
|
---|
49 | use util;
|
---|
50 | #use solrutil;
|
---|
51 | use solrserver;
|
---|
52 |
|
---|
53 | sub print_usage {
|
---|
54 | print STDERR "\nUsage:\t$0 start\n\t$0 stop\n\n";
|
---|
55 | exit 1;
|
---|
56 | }
|
---|
57 |
|
---|
58 | sub main
|
---|
59 | {
|
---|
60 | my (@argv) = @_;
|
---|
61 | my $argc = scalar(@argv);
|
---|
62 |
|
---|
63 | # defaults and fall-backs
|
---|
64 | my $verbosity = 2;
|
---|
65 | my $command = "stop";
|
---|
66 | #my $stopkey = "standalone-greenstone-solr";
|
---|
67 |
|
---|
68 |
|
---|
69 | if ($argc < 1 || $argc > 2) {
|
---|
70 | print_usage();
|
---|
71 | }
|
---|
72 |
|
---|
73 | if($argv[0] ne "start" && $argv[0] ne "stop") {
|
---|
74 | print_usage();
|
---|
75 | } else {
|
---|
76 | $command = $argv[0]
|
---|
77 | }
|
---|
78 |
|
---|
79 | #if($argc > 1) {
|
---|
80 | # $stopkey = $argv[1];
|
---|
81 | #}
|
---|
82 |
|
---|
83 | my $solr_server = new solrserver();
|
---|
84 | #$solr_server->set_jetty_stop_key($stopkey);
|
---|
85 |
|
---|
86 | if ($command eq "start") {
|
---|
87 | $solr_server->start($verbosity);
|
---|
88 | } elsif ($command eq "stop") {
|
---|
89 | my $options = { 'output_verbosity' => $verbosity };
|
---|
90 | $solr_server->stop($options);
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 |
|
---|
95 | &main(@ARGV);
|
---|