def _spawn_nailgun_server(self): log.info('No ng server found, spawning...') with _safe_open(self._ng_out, 'w'): pass # truncate pid = os.fork() if pid != 0: # In the parent tine - block on ng being up for connections return self._await_nailgun_server() os.setsid() in_fd = open('/dev/null', 'w') out_fd = safe_open(self._ng_out, 'w') err_fd = safe_open(self._ng_err, 'w') args = ['java'] if self._ng_server_args: args.extend(self._ng_server_args) args.append(NailgunTask.PANTS_NG_ARG) args.append(NailgunTask.create_pidfile_arg(self._pidfile)) args.extend(['-jar', self._nailgun_jar, ':0']) log.debug('Executing: %s' % ' '.join(args)) with binary_utils.safe_classpath(logger=log.warn): process = subprocess.Popen(args, stdin=in_fd, stdout=out_fd, stderr=err_fd, close_fds=True, cwd=get_buildroot()) with _safe_open(self._pidfile, 'w') as pidfile: pidfile.write('%d' % process.pid) log.debug('Spawned ng server @ %d' % process.pid) sys.exit(0)
def _spawn_nailgun_server(self): log.info('No ng server found, spawning...') with _safe_open(self._ng_out, 'w'): pass # truncate if os.path.exists(self._pidfile): os.remove( self._pidfile) # So we know when the child has written it. pid = os.fork() if pid != 0: # In the parent tine - block on ng being up for connections return self._await_nailgun_server() os.setsid() in_fd = open('/dev/null', 'w') out_fd = safe_open(self._ng_out, 'w') err_fd = safe_open(self._ng_err, 'w') args = ['java'] if self._ng_server_args: args.extend(self._ng_server_args) args.append(NailgunTask.PANTS_NG_ARG) args.append(NailgunTask.create_pidfile_arg(self._pidfile)) args.extend(['-jar', self._nailgun_jar, ':0']) log.debug('Executing: %s' % ' '.join(args)) with binary_utils.safe_classpath(logger=log.warn): process = subprocess.Popen(args, stdin=in_fd, stdout=out_fd, stderr=err_fd, close_fds=True, cwd=get_buildroot()) with _safe_open(self._pidfile, 'w') as pidfile: pidfile.write('%d' % process.pid) log.debug('Spawned ng server @ %d' % process.pid) # Prevents finally blocks being executed, unlike sys.exit(). We don't want to execute finally # blocks because we might, e.g., clean up tempfiles that the parent still needs. os._exit(0)
def _spawn_nailgun_server(self): log.info('No ng server found, spawning...') with _safe_open(self._ng_out, 'w'): pass # truncate pid = os.fork() if pid != 0: # In the parent tine - block on ng being up for connections return self._await_nailgun_server() os.setsid() in_fd = open('/dev/null', 'w') out_fd = safe_open(self._ng_out, 'w') err_fd = safe_open(self._ng_err, 'w') args = ['java'] if self._ng_server_args: args.extend(self._ng_server_args) args.append(NailgunTask.PANTS_NG_ARG) args.append(NailgunTask.create_pidfile_arg(self._pidfile)) args.extend(['-jar', self._nailgun_jar, ':0']) log.debug('Executing: %s' % ' '.join(args)) with binary_utils.safe_classpath(logger=log.warn): process = subprocess.Popen( args, stdin=in_fd, stdout=out_fd, stderr=err_fd, close_fds=True, cwd=get_buildroot() ) with _safe_open(self._pidfile, 'w') as pidfile: pidfile.write('%d' % process.pid) log.debug('Spawned ng server @ %d' % process.pid) # Prevents finally blocks being executed, unlike sys.exit(). We don't want to execute finally # blocks because we might, e.g., clean up tempfiles that the parent still needs. os._exit(0)
def _spawn_nailgun_server(self): log.info('No ng server found, spawning...') with _safe_open(self._ng_out, 'w'): pass # truncate pid = os.fork() if pid != 0: # In the parent tine - block on ng being up for connections return self._await_nailgun_server() os.setsid() in_fd = open('/dev/null', 'w') out_fd = safe_open(self._ng_out, 'w') err_fd = safe_open(self._ng_err, 'w') args = ['java'] if self._ng_server_args: args.extend(self._ng_server_args) args.append(NailgunTask.PANTS_NG_ARG) args.append('-Dpidfile=%s' % os.path.relpath(self._pidfile, get_buildroot())) args.extend(['-jar', self._nailgun_jar, ':0']) log.debug('Executing: %s' % ' '.join(args)) with binary_utils.safe_classpath(logger=log.warn): process = subprocess.Popen( args, stdin=in_fd, stdout=out_fd, stderr=err_fd, close_fds=True, cwd=get_buildroot() ) with _safe_open(self._pidfile, 'w') as pidfile: pidfile.write('%d' % process.pid) log.debug('Spawned ng server @ %d' % process.pid) sys.exit(0)
def _spawn_nailgun_server(self): log.info("No ng server found, spawning...") with _safe_open(self._ng_out, "w"): pass # truncate if os.path.exists(self._pidfile): os.remove(self._pidfile) # So we know when the child has written it. pid = os.fork() if pid != 0: # In the parent tine - block on ng being up for connections return self._await_nailgun_server() os.setsid() in_fd = open("/dev/null", "w") out_fd = safe_open(self._ng_out, "w") err_fd = safe_open(self._ng_err, "w") args = ["java"] if self._ng_server_args: args.extend(self._ng_server_args) args.append(NailgunTask.PANTS_NG_ARG) args.append(NailgunTask.create_pidfile_arg(self._pidfile)) args.extend(["-jar", self._nailgun_jar, ":0"]) log.debug("Executing: %s" % " ".join(args)) with binary_utils.safe_classpath(logger=log.warn): process = subprocess.Popen( args, stdin=in_fd, stdout=out_fd, stderr=err_fd, close_fds=True, cwd=get_buildroot() ) with _safe_open(self._pidfile, "w") as pidfile: pidfile.write("%d" % process.pid) log.debug("Spawned ng server @ %d" % process.pid) # Prevents finally blocks being executed, unlike sys.exit(). We don't want to execute finally # blocks because we might, e.g., clean up tempfiles that the parent still needs. os._exit(0)