source: main/trunk/gli/src/org/greenstone/gatherer/util/GS3ServerThread.java@ 29222

Last change on this file since 29222 was 29222, checked in by ak19, 10 years ago

SOLR related. TEMPORARY changes for the GS3 workshop. Owing to the change to Solr 4.7.2, solr collections can't re-build despite activate if the GS3 server is running because there is a conflict with the jetty server launched by buildcol and jetty finds a lock on the index. The result is that one can't search the solr index after such a rebuild. Dr Bainbridge suggested a temporary measure: instead of commandline building solr collections, we will now build them in GLI. GLI will build solr collections with activate on but, for solr collections alone, it will stop the GS3 server before a build and start it again upon completion. In future, we will get rid of the solr jetty server and just have solr running over HTTP from tomcat. The Java GS3 runtime code will have to access Solr as a HTTPSolrServer rather than as an EmbeddedSolrServer at that point.

File size: 2.7 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * <BR><BR>
9 *
10 * Author: Sam McIntosh, Greenstone Digital Library, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 2011 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *########################################################################
36 */
37
38package org.greenstone.gatherer.util;
39import java.io.File;
40
41/** Class for GS3, for issuing ant commands from GLI */
42public class GS3ServerThread extends Thread
43{
44 String _gsdl3_src_path = "";
45 String _ant_command = "";
46
47 public GS3ServerThread(String gsdl3_src_path, String ant_command)
48 {
49 _gsdl3_src_path = gsdl3_src_path;
50 _ant_command = ant_command; // "restart"
51 }
52
53 public void run()
54 {
55 try
56 {
57 ///System.err.println("**** GS3 server : " + _ant_command);
58
59 String shellCommand = null;
60 Process p = null;
61 if (Utility.isWindows())
62 {
63 if(_ant_command.indexOf("start") != -1) { // running an "ant (re)start" command on windows, run start
64 _ant_command = "start";
65 }
66 // The path in quotes, and the entire sequence of commands in quotes as well
67 // E.g. the following works: cmd /C "cd "C:\path\to\greenstone3" && ant stop"
68 // and it preserves any spaces in the path to GSDL3SRCHOME (_gsdl3_src_path).
69 p = Runtime.getRuntime().exec("cmd /C \"cd \"" + _gsdl3_src_path + File.separator + "\" && ant " + _ant_command + "\"");
70 }
71 else
72 {
73 if(_ant_command.indexOf("start") != -1) { // if running an "ant (re)start" command on non-Windows, run restart
74 _ant_command = "restart";
75 }
76 p = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "ant " + _ant_command + " -f \"" + _gsdl3_src_path + File.separator + "build.xml\""});
77 }
78 }
79 catch(Exception ex)
80 {
81 ex.printStackTrace();
82 }
83 }
84}
Note: See TracBrowser for help on using the repository browser.