<commit_before>package com.github.kuldeepg.springbootutility

import groovyx.net.http.RESTClient
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

/**
 * Created by Kuldeep on 9/21/15.
 */
class DaemonStartTask extends DefaultTask {
    ApplicationSetting settings = new ApplicationSetting()

    DaemonStartTask configure(Closure config){
        config.resolveStrategy = Closure.DELEGATE_ONLY
        config.delegate = this
        config()
        this
    }

    @TaskAction
    def startDaemon(){
        DaemonEnvironment environmentSettings = getProject().getExtensions().findByName("springBootDaemonize")

        File logFile = project.file(settings.logfile)

        def processArgs = ([
                environmentSettings.javaExec,
                new String("-Dserver.port=${settings.serverPort}"),
                new String("-Dspring.profiles.active=${settings.serverProfile}"),
                new String("-Dspring.config.location=${settings.propertiesFile}"),
                "-Dcom.sun.management.jmxremote",
                new String("-Dcom.sun.management.jmxremote.port=${settings.jmxPort}"),
                "-Dcom.sun.management.jmxremote.authenticate=false",
                "-Dcom.sun.management.jmxremote.ssl=false",
                new String("-Djava.rmi.server.hostname=${settings.ipAddress}"),
                settings.jvmArgs,
                "-jar",
                settings.warFile,
        ]).flatten()

        ProcessBuilder processBuilder = new ProcessBuilder(processArgs)

        processBuilder.directory(project.file('.'))
        processBuilder.redirectErrorStream(true)
        processBuilder.redirectOutput(logFile)

        Process process = processBuilder.start()
        Integer waitInSecs = settings.maxWait
        String url = new String("http://${settings.ipAddress}:${settings.serverPort}/")
        
        RESTClient client = new RESTClient(url)
        client.getClient().getParams().setParameter("http.connection.timeout", 5000)
        client.getClient().getParams().setParameter("http.socket.timeout", 5000)

        while(waitInSecs > 0) {
            try {
                client.options path: settings.serverValidationPath
                break
            } catch(ex) {
                    waitInSecs -= 1
                    sleep 1000
            }
        }
        if(waitInSecs == 0) {
            process.destroy()
            assert false, "${settings.name} daemon couldn't be started within ${settings.maxWait} seconds. Check the ${settings.logfile} to see possible errors, or increase the maxWait time."
        }

        println "${settings.name} daemon successfully started on port: ${settings.serverPort}."
        println "========================================================================================================"
        println "Daemon name            : ${settings.name}"
        println "Server port            : ${settings.serverPort}"
        println "Spring profile         : ${settings.serverProfile}"
        println "JMX port               : ${settings.jmxPort}"
        println "IP address             : ${settings.ipAddress}"
        println "Logfile                : ${settings.logfile}"
        println "Additional JVM args    : ${settings.jvmArgs}"
        println "========================================================================================================"

        assert true
    }
}
<commit_msg>more logs<commit_after>package com.github.kuldeepg.springbootutility

import groovyx.net.http.RESTClient
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

/**
 * Created by Kuldeep on 9/21/15.
 */
class DaemonStartTask extends DefaultTask {
    ApplicationSetting settings = new ApplicationSetting()

    DaemonStartTask configure(Closure config){
        config.resolveStrategy = Closure.DELEGATE_ONLY
        config.delegate = this
        config()
        this
    }

    @TaskAction
    def startDaemon(){
        DaemonEnvironment environmentSettings = getProject().getExtensions().findByName("springBootDaemonize")

        File logFile = project.file(settings.logfile)

        def processArgs = ([
                environmentSettings.javaExec,
                new String("-Dserver.port=${settings.serverPort}"),
                new String("-Dspring.profiles.active=${settings.serverProfile}"),
                new String("-Dspring.config.location=${settings.propertiesFile}"),
                "-Dcom.sun.management.jmxremote",
                new String("-Dcom.sun.management.jmxremote.port=${settings.jmxPort}"),
                "-Dcom.sun.management.jmxremote.authenticate=false",
                "-Dcom.sun.management.jmxremote.ssl=false",
                new String("-Djava.rmi.server.hostname=${settings.ipAddress}"),
                settings.jvmArgs,
                "-jar",
                settings.warFile,
        ]).flatten()

        ProcessBuilder processBuilder = new ProcessBuilder(processArgs)

        processBuilder.directory(project.file('.'))
        processBuilder.redirectErrorStream(true)
        processBuilder.redirectOutput(logFile)

        Process process = processBuilder.start()
        Integer waitInSecs = settings.maxWait
        String url = new String("http://${settings.ipAddress}:${settings.serverPort}/")

        println "url: ${url}"
        RESTClient client = new RESTClient(url)
        client.getClient().getParams().setParameter("http.connection.timeout", 5000)
        client.getClient().getParams().setParameter("http.socket.timeout", 5000)

        while(waitInSecs > 0) {
            try {
                println "path: ${settings.serverValidationPath}"
                client.options path: settings.serverValidationPath
                break
            } catch(ex) {
                    waitInSecs -= 1
                    sleep 1000
            }
        }
        if(waitInSecs == 0) {
            process.destroy()
            assert false, "${settings.name} daemon couldn't be started within ${settings.maxWait} seconds. Check the ${settings.logfile} to see possible errors, or increase the maxWait time."
        }

        println "${settings.name} daemon successfully started on port: ${settings.serverPort}."
        println "========================================================================================================"
        println "Daemon name            : ${settings.name}"
        println "Server port            : ${settings.serverPort}"
        println "Spring profile         : ${settings.serverProfile}"
        println "JMX port               : ${settings.jmxPort}"
        println "IP address             : ${settings.ipAddress}"
        println "Logfile                : ${settings.logfile}"
        println "Additional JVM args    : ${settings.jvmArgs}"
        println "========================================================================================================"

        assert true
    }
}

{'fraction_non_alphanumeric': 0.1632447954055994, 'fraction_numerical': 0.00574300071787509, 'mean_word_length': 2.386485172581429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1568143', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1647, 'n_words': 329}