Changeset 24333 for main/trunk/gli/src


Ignore:
Timestamp:
2011-07-25T16:25:49+12:00 (13 years ago)
Author:
ak19
Message:
  1. Sam had already update GLI for GS3 to issue ant start calls on starting up, so that the preview button would work for GLI running against GS3. Now an ant stop call is issued on GLI exit to match the startup sequence (note that this needs to be done in the main thread since we don't want GLI's main thread to exit which may then not have resulted in an ant stop being issued in a timely manner from its own separate GS3ServerThread). 2. Sam's GS3ServerThread class moved into its own class file.
Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r24296 r24333  
    5858import org.greenstone.gatherer.metadata.FilenameEncoding;
    5959import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
     60import org.greenstone.gatherer.util.GS3ServerThread;
    6061import org.greenstone.gatherer.util.JarTools;
    6162import org.greenstone.gatherer.util.StaticStrings;
     
    372373                }
    373374                else {
    374                     GS3ServerThread thread = new GS3ServerThread(gsdl_path);
     375                    GS3ServerThread thread = new GS3ServerThread(gsdl_path, "start");
    375376                    thread.start();
    376377                }
     
    705706        if (isGsdlRemote) {
    706707            remoteGreenstoneServer.exit();
     708        } else if (GS3) { // stop the local tomcat web server when running GS3
     709            // can't call ant stop from its own thread - what if GLI has exited by then?
     710            // issue call to ant stop from the main GLI thread
     711            //GS3ServerThread thread = new GS3ServerThread(Configuration.gsdl_path, "stop");
     712            //thread.start();
     713
     714            try {
     715            String shellCommand = null;
     716            Process p = null;
     717            if (Utility.isWindows()) {             
     718                p = Runtime.getRuntime().exec("cmd /C \"cd " + Configuration.gsdl_path + File.separator + ".. && ant stop\"\"");   
     719            } else {
     720                p = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "ant stop -f \"" + Configuration.gsdl_path + ".." + File.separator + "build.xml\""});
     721            }
     722            } catch(Exception e) {
     723            System.err.println("Exception when trying to stop the tomcat web server: " + e);
     724            DebugStream.printStackTrace(e);
     725            }
     726           
    707727        }
    708728
     
    15951615    }
    15961616   
    1597     public class GS3ServerThread extends Thread
    1598     {
    1599         String _gsdl_path = "";
    1600        
    1601         public GS3ServerThread(String gsdl_path)
    1602         {
    1603             _gsdl_path = gsdl_path;
    1604         }
    1605        
    1606         public void run()
    1607         {
    1608             try
    1609             {
    1610                 String shellCommand = null;
    1611                 Process p = null;
    1612                 if (Utility.isWindows())
    1613                 {
    1614                     p = Runtime.getRuntime().exec("cmd /C \"cd " + _gsdl_path + File.separator + ".. && ant start\"\"");   
    1615                 }
    1616                 else
    1617                 {
    1618                     p = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "ant restart -f \"" + _gsdl_path + ".." + File.separator + "build.xml\""});
    1619                 }
    1620             }
    1621             catch(Exception ex)
    1622             {
    1623                 ex.printStackTrace();
    1624             }
    1625         }
    1626     }
    16271617}
Note: See TracChangeset for help on using the changeset viewer.