@@ -293,9 +293,7 @@ abstract class ForkedGrailsProcess {
293293 GrailsConsole . instance. updateStatus(" Running without daemon..." )
294294 }
295295
296- ServerSocket parentAvailabilityServer = new ServerSocket (0 )
297- def parentPort = parentAvailabilityServer. localPort
298- System . setProperty(PARENT_PROCESS_PORT , String . valueOf(parentPort))
296+ ServerSocket parentAvailabilityServer = startParentAvailabilityServer()
299297
300298 try {
301299 String classpathString = getBoostrapClasspath(executionContext)
@@ -335,6 +333,13 @@ abstract class ForkedGrailsProcess {
335333 }
336334 }
337335
336+ protected ServerSocket startParentAvailabilityServer () {
337+ ServerSocket parentAvailabilityServer = new ServerSocket (0 )
338+ def parentPort = parentAvailabilityServer. localPort
339+ System . setProperty(PARENT_PROCESS_PORT , String . valueOf(parentPort))
340+ parentAvailabilityServer
341+ }
342+
338343 @CompileStatic
339344 protected void runDaemonCommand (String daemonCmd ) {
340345 def clientSocket = new Socket (" localhost" , daemonPort)
@@ -517,7 +522,11 @@ abstract class ForkedGrailsProcess {
517522 if (! (System . getProperty(" java.version" ) =~ / 1.[89]./ )) {
518523 cmd. add(" -XX:MaxPermSize=${ maxPerm} m" . toString())
519524 }
520- cmd << " -D${ PARENT_PROCESS_PORT} =${ System.getProperty(PARENT_PROCESS_PORT)} " . toString()
525+ def parentPort = System . getProperty(PARENT_PROCESS_PORT )
526+ if (parentPort) {
527+ cmd << " -D${ PARENT_PROCESS_PORT} =${ parentPort} " . toString()
528+ }
529+
521530 cmd. addAll([" -Dgrails.fork.active=true" ,
522531 " -Dgrails.build.execution.context=${ tempFile.canonicalPath} " . toString(), " -cp" , classpathString])
523532
0 commit comments