Search in sources :

Example 1 with TLSCertificates

use of com.ociweb.pronghorn.network.TLSCertificates in project GreenLightning by oci-pronghorn.

the class GreenLightning method main.

public static void main(String[] args) {
    String path = HTTPServer.getOptArg("-site", "--s", args, null);
    String resourceRoot = HTTPServer.getOptArg("-resourcesRoot", "--rr", args, null == path ? "/site/index.html" : null);
    String rootFolder = null;
    if (null == path) {
        if (null == resourceRoot) {
            System.out.println("Path to site must be defined with -site or --s");
            return;
        } else {
            // use internal resources
            int endOfRoot = resourceRoot.lastIndexOf('/');
            if (-1 == endOfRoot) {
                System.out.println("resourceRoot must contain at least one / to define the subfolder inside the resources folder");
                return;
            }
            rootFolder = resourceRoot.substring(0, endOfRoot);
            System.out.println("reading site data from internal resources: " + rootFolder);
        }
    } else {
        if (null == resourceRoot) {
            // normal file path site
            System.out.println("reading site data from: " + path);
        } else {
            System.out.println("use -size for file paths or -resourcesRoot for packaged resources. Only one can be used at a time.");
            return;
        }
    }
    String isTLS = HTTPServer.getOptArg("-tls", "--t", args, "True");
    String isLarge = HTTPServer.getOptArg("-large", "--l", args, "False");
    String strPort = HTTPServer.getOptArg("-port", "--p", args, "8080");
    int port = Integer.parseInt(strPort);
    String bindHost = HTTPServer.getOptArg("-host", "--h", args, null);
    boolean large = Boolean.parseBoolean(isLarge);
    if (null == bindHost) {
        bindHost = bindHost();
    }
    // makes big performance difference.
    final int fileOutgoing = large ? 2048 : 1024;
    final int fileChunkSize = large ? 1 << 14 : 1 << 10;
    int processors = large ? 8 : -1;
    GraphManager gm = new GraphManager();
    TLSCertificates certs = Boolean.parseBoolean(isTLS) ? TLSCertificates.defaultCerts : null;
    HTTPServer.startupHTTPServer(gm, processors, GreenLightning.simpleModuleConfig(path, resourceRoot, rootFolder, fileOutgoing, fileChunkSize), bindHost, port, certs);
    System.out.println("Press \"ENTER\" to exit...");
    int value = -1;
    do {
        try {
            value = System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } while (value != 10);
    System.exit(0);
}
Also used : TLSCertificates(com.ociweb.pronghorn.network.TLSCertificates) GraphManager(com.ociweb.pronghorn.stage.scheduling.GraphManager) IOException(java.io.IOException)

Aggregations

TLSCertificates (com.ociweb.pronghorn.network.TLSCertificates)1 GraphManager (com.ociweb.pronghorn.stage.scheduling.GraphManager)1 IOException (java.io.IOException)1