Package: org.codehaus.groovy.grails.cli.fork

## [Groovy] Class ForkedGrailsProcess

- org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess

- Helper class for kicking off forked JVM processes, helpful in managing the setup and execution of the forked process. Subclasses should provided a static void main method.

  Authors:
    Graeme Rocher
  Since:
    2.2

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `ForkedGrailsProcess.TextDumper` |

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static java.lang.String` | `DEBUG_FORK` |
    `static int` | `DEFAULT_DAEMON_PORT` |
    `static java.lang.String` | `DEFAULT_DEBUG_ARGS` |
    `static java.lang.String` | `PARENT_PROCESS_PORT` |

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `boolean` | `daemon`
    `int` | `daemonPort`
    `boolean` | `debug`
    `java.lang.String` | `debugArgs`
    `java.lang.String` | `encoding`
    `ExecutionContext` | `executionContext`
    `boolean` | `forkReserve`
    `java.net.URLClassLoader` | `forkedClassLoader`
    `java.util.List<java.lang.String>` | `jvmArgs`
    `int` | `maxMemory`
    `int` | `maxPerm`
    `int` | `minMemory`
    `boolean` | `reloading`
    `java.io.File` | `reloadingAgent`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ForkedGrailsProcess ()`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `protected java.lang.Process` | `attachOutputListener(java.lang.Process process, boolean async = false)`
    `protected java.util.List<java.io.File>` | `buildMinimalIsolatedClasspath(BuildSettings buildSettings)`
    `protected java.util.List<java.lang.String>` | `buildProcessCommand(ExecutionContext executionContext, java.lang.String classpathString, boolean isReserve = false, boolean isDaemon = false)`
    `void` | `configure(java.util.Map forkConfig)`
    `protected void` | `configureFork(BuildSettings buildSettings)`
    `protected groovy.lang.GroovyClassLoader` | `createClassLoader(BuildSettings buildSettings)`
    `protected void` | `discoverAndSetAgent(ExecutionContext executionContext)`
    `protected java.io.File` | `findJarFile(java.lang.Class targetClass)`
    `java.util.Collection<java.io.File>` | `findSystemClasspathJars(BuildSettings buildSettings)`
    `protected java.io.File` | `findToolsJar()`
    `java.lang.Process` | `fork(java.util.Map argsMap = new LinkedHashMap()`
    `void` | `forkDaemon(ExecutionContext executionContext = getExecutionContext()`
    `void` | `forkReserve(ExecutionContext executionContext = getExecutionContext()`
    `protected void` | `forkReserveProcess(java.util.List<java.lang.String> cmd, ExecutionContext executionContext, boolean attachListener = true)`
    `protected java.lang.String` | `getBoostrapClasspath(ExecutionContext executionContext)`
    `protected java.io.File` | `getResumeDir()`
    `protected BuildSettings` | `initializeBuildSettings(ExecutionContext ec)`
    `protected java.net.URLClassLoader` | `initializeClassLoader(BuildSettings buildSettings)`
    `protected void` | `initializeLogging(java.io.File grailsHome, java.lang.ClassLoader classLoader)`
    `protected boolean` | `isDaemonProcess()` @return Whether this process should be launched using a running daemon process.
    `boolean` | `isDaemonRunning()`
    `protected boolean` | `isDebugForkEnabled()`
    `boolean` | `isForkingReserveEnabled()`
    `protected boolean` | `isReserveProcess()` Returns: Whether this process is a reserve process.
    `boolean` | `isServerRunning(int port)` @return Whether the server is running
    `protected boolean` | `isWindows()`
    `void` | `killAfterTimeout()`
    `ExecutionContext` | `readExecutionContext()`
    `protected ExecutionContext` | `readExecutionContext(java.lang.String location)`
    `static java.lang.String` | `readLine(java.io.InputStream inputStream)`
    `void` | `restartDaemon(ExecutionContext executionContext = getExecutionContext()`
    `protected void` | `runDaemonCommand(java.lang.String daemonCmd)`
    `protected void` | `setupReloading(java.net.URLClassLoader classLoader, BuildSettings buildSettings)` @param classLoader
    `protected boolean` | `shouldRunWithDaemon()`
    `void` | `startDaemon(groovy.lang.Closure callable)`
    `protected void` | `startParentAvailabilityServer()`
    `protected void` | `startParentPortMonitor()`
    `protected void` | `startProjectWatcher(java.net.URLClassLoader classLoader, BuildSettings buildSettings)`
    `protected java.io.File` | `storeExecutionContext(ExecutionContext executionContext)`
    `protected void` | `waitForResume()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### public static final java.lang.String DEBUG_FORK

    - #### public static final int DEFAULT_DAEMON_PORT

    - #### public static final java.lang.String DEFAULT_DEBUG_ARGS

    - #### public static final java.lang.String PARENT_PROCESS_PORT

  - ### Property Detail

    - #### boolean daemon

    - #### int daemonPort

    - #### boolean debug

    - #### java.lang.String debugArgs

    - #### java.lang.String encoding

    - #### ExecutionContext executionContext

    - #### boolean forkReserve

    - #### java.net.URLClassLoader forkedClassLoader

    - #### java.util.List<java.lang.String> jvmArgs

    - #### int maxMemory

    - #### int maxPerm

    - #### int minMemory

    - #### boolean reloading

    - #### java.io.File reloadingAgent

  - ### Constructor Detail

    - #### ForkedGrailsProcess()

  - ### Method Detail

    - #### @groovy.transform.CompileStatic protected java.lang.Process attachOutputListener(java.lang.Process process, boolean async = false)

    - #### @groovy.transform.CompileStatic protected java.util.List<java.io.File> buildMinimalIsolatedClasspath(BuildSettings buildSettings)

    - #### @groovy.transform.CompileStatic protected java.util.List<java.lang.String> buildProcessCommand(ExecutionContext executionContext, java.lang.String classpathString, boolean isReserve = false, boolean isDaemon = false)

    - #### @groovy.transform.CompileStatic void configure(java.util.Map forkConfig)

    - #### protected void configureFork(BuildSettings buildSettings)

    - #### @groovy.transform.CompileStatic protected groovy.lang.GroovyClassLoader createClassLoader(BuildSettings buildSettings)

    - #### @groovy.transform.CompileStatic protected void discoverAndSetAgent(ExecutionContext executionContext)

    - #### @groovy.transform.CompileStatic protected java.io.File findJarFile(java.lang.Class targetClass)

    - #### @groovy.transform.CompileStatic java.util.Collection<java.io.File> findSystemClasspathJars(BuildSettings buildSettings)

    - #### @groovy.transform.CompileStatic protected java.io.File findToolsJar()

    - #### @groovy.transform.CompileStatic java.lang.Process fork(java.util.Map argsMap = new LinkedHashMap()

    - #### @groovy.transform.CompileStatic void forkDaemon(ExecutionContext executionContext = getExecutionContext()

    - #### @groovy.transform.CompileStatic void forkReserve(ExecutionContext executionContext = getExecutionContext()

    - #### @groovy.transform.CompileStatic protected void forkReserveProcess(java.util.List<java.lang.String> cmd, ExecutionContext executionContext, boolean attachListener = true)

    - #### @groovy.transform.CompileStatic protected java.lang.String getBoostrapClasspath(ExecutionContext executionContext)

    - #### protected java.io.File getResumeDir()

    - #### @groovy.transform.CompileStatic protected BuildSettings initializeBuildSettings(ExecutionContext ec)

    - #### @groovy.transform.CompileStatic protected java.net.URLClassLoader initializeClassLoader(BuildSettings buildSettings)

    - #### protected void initializeLogging(java.io.File grailsHome, java.lang.ClassLoader classLoader)

    - #### protected boolean isDaemonProcess()

      Returns:
        Whether this process should be launched using a running daemon process.

    - #### boolean isDaemonRunning()

    - #### @groovy.transform.CompileStatic protected boolean isDebugForkEnabled()

    - #### @groovy.transform.CompileStatic boolean isForkingReserveEnabled()

    - #### protected boolean isReserveProcess()

      Returns:
        Whether this process is a reserve process. A reserve process is an additional JVM, bootstrapped and idle that can resume execution at a later date

    - #### boolean isServerRunning(int port)

      Returns:
        Whether the server is running

    - #### @groovy.transform.CompileStatic protected boolean isWindows()

    - #### @groovy.transform.CompileStatic void killAfterTimeout()

    - #### @groovy.transform.CompileStatic ExecutionContext readExecutionContext()

    - #### @groovy.transform.CompileStatic protected ExecutionContext readExecutionContext(java.lang.String location)

    - #### @groovy.transform.CompileStatic static java.lang.String readLine(java.io.InputStream inputStream)

    - #### @groovy.transform.CompileStatic void restartDaemon(ExecutionContext executionContext = getExecutionContext()

    - #### @groovy.transform.CompileStatic protected void runDaemonCommand(java.lang.String daemonCmd)

    - #### protected void setupReloading(java.net.URLClassLoader classLoader, BuildSettings buildSettings)

      Parameters:
        classLoader
        buildSettings

    - #### @groovy.transform.CompileStatic protected boolean shouldRunWithDaemon()

    - #### @groovy.transform.CompileStatic void startDaemon(groovy.lang.Closure callable)

    - #### protected void startParentAvailabilityServer()

    - #### protected void startParentPortMonitor()

    - #### protected void startProjectWatcher(java.net.URLClassLoader classLoader, BuildSettings buildSettings)

    - #### protected java.io.File storeExecutionContext(ExecutionContext executionContext)

    - #### @groovy.transform.CompileStatic protected void waitForResume()