Search in sources :

Example 1 with Main

use of org.locationtech.geogig.web.Main in project GeoGig by boundlessgeo.

the class Serve method runInternal.

@Override
protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException {
    String loc = repo != null && repo.size() > 0 ? repo.get(0) : ".";
    GeoGIG geogig = loadGeoGIG(loc, cli);
    Application application = new Main(geogig);
    Component comp = new Component();
    comp.getDefaultHost().attach(application);
    comp.getServers().add(Protocol.HTTP, port);
    cli.getConsole().println(String.format("Starting server on port %d, use CTRL+C to exit.", port));
    try {
        comp.start();
        cli.setExitOnFinish(false);
    } catch (BindException e) {
        String msg = String.format("Port %d already in use, use the --port parameter to specify a different port", port);
        throw new CommandFailedException(msg, e);
    } catch (Exception e) {
        throw new CommandFailedException("Unable to start server", e);
    }
}
Also used : BindException(java.net.BindException) Component(org.restlet.Component) Application(org.restlet.Application) Main(org.locationtech.geogig.web.Main) GeoGIG(org.locationtech.geogig.api.GeoGIG) CommandFailedException(org.locationtech.geogig.cli.CommandFailedException) IOException(java.io.IOException) BindException(java.net.BindException) InvalidParameterException(org.locationtech.geogig.cli.InvalidParameterException) CommandFailedException(org.locationtech.geogig.cli.CommandFailedException)

Aggregations

IOException (java.io.IOException)1 BindException (java.net.BindException)1 GeoGIG (org.locationtech.geogig.api.GeoGIG)1 CommandFailedException (org.locationtech.geogig.cli.CommandFailedException)1 InvalidParameterException (org.locationtech.geogig.cli.InvalidParameterException)1 Main (org.locationtech.geogig.web.Main)1 Application (org.restlet.Application)1 Component (org.restlet.Component)1