def create(cls, bootstrap_options=None): """ :param Options bootstrap_options: The bootstrap options, if available. """ bootstrap_options = bootstrap_options or cls._parse_bootstrap_options( ) bootstrap_options_values = bootstrap_options.for_global_scope() build_root = get_buildroot() native = Native.create(bootstrap_options_values) # TODO: https://github.com/pantsbuild/pants/issues/3479 watchman = WatchmanLauncher.create( bootstrap_options_values).watchman legacy_graph_helper = cls._setup_legacy_graph_helper( native, bootstrap_options_values) services, port_map = cls._setup_services(build_root, bootstrap_options_values, legacy_graph_helper, watchman) return PantsDaemon(native, build_root, bootstrap_options_values.pants_workdir, bootstrap_options_values.level.upper(), services, port_map, bootstrap_options_values.pants_subprocessdir, bootstrap_options)
def create(cls, bootstrap_options=None): """ :param Options bootstrap_options: The bootstrap options, if available. """ bootstrap_options = bootstrap_options or cls._parse_bootstrap_options() bootstrap_options_values = bootstrap_options.for_global_scope() build_root = get_buildroot() native = Native.create(bootstrap_options_values) # TODO: https://github.com/pantsbuild/pants/issues/3479 watchman = WatchmanLauncher.create(bootstrap_options_values).watchman legacy_graph_helper = cls._setup_legacy_graph_helper(native, bootstrap_options_values) services, port_map = cls._setup_services( build_root, bootstrap_options_values, legacy_graph_helper, watchman ) return PantsDaemon( native, build_root, bootstrap_options_values.pants_workdir, bootstrap_options_values.level.upper(), services, port_map, bootstrap_options_values.pants_subprocessdir, bootstrap_options )
def create(cls, options_bootstrapper, full_init=True) -> "PantsDaemon": """ :param OptionsBootstrapper options_bootstrapper: The bootstrap options. :param bool full_init: Whether or not to fully initialize an engine et al for the purposes of spawning a new daemon. `full_init=False` is intended primarily for lightweight lifecycle checks (since there is a ~1s overhead to initialize the engine). See the impl of `maybe_launch` for an example of the intended usage. """ bootstrap_options = options_bootstrapper.bootstrap_options bootstrap_options_values = bootstrap_options.for_global_scope() native: Optional[Native] = None build_root: Optional[str] = None if full_init: build_root = get_buildroot() native = Native() build_config = BuildConfigInitializer.get(options_bootstrapper) legacy_graph_scheduler = EngineInitializer.setup_legacy_graph( native, options_bootstrapper, build_config) # TODO: https://github.com/pantsbuild/pants/issues/3479 watchman = WatchmanLauncher.create( bootstrap_options_values).watchman services = cls._setup_services( build_root, bootstrap_options_values, legacy_graph_scheduler, native, watchman, union_membership=UnionMembership( build_config.union_rules()), ) else: services = PantsServices() return PantsDaemon( native=native, build_root=build_root, work_dir=bootstrap_options_values.pants_workdir, log_level=bootstrap_options_values.level, services=services, metadata_base_dir=bootstrap_options_values.pants_subprocessdir, bootstrap_options=bootstrap_options, )
def _setup_services( bootstrap_options: OptionValueContainer, legacy_graph_scheduler: LegacyGraphScheduler, ): """Initialize pantsd services. :returns: A PantsServices instance. """ build_root = get_buildroot() # TODO: https://github.com/pantsbuild/pants/issues/3479 watchman_launcher = WatchmanLauncher.create(bootstrap_options) watchman_launcher.maybe_launch() watchman = watchman_launcher.watchman fs_event_service = (FSEventService( watchman, scheduler=legacy_graph_scheduler.scheduler, build_root=build_root) if bootstrap_options.watchman_enable else None) invalidation_globs = OptionsInitializer.compute_pantsd_invalidation_globs( build_root, bootstrap_options, PantsDaemon.metadata_file_path( "pantsd", "pid", bootstrap_options.pants_subprocessdir), ) scheduler_service = SchedulerService( fs_event_service=fs_event_service, legacy_graph_scheduler=legacy_graph_scheduler, build_root=build_root, invalidation_globs=invalidation_globs, max_memory_usage_pid=os.getpid(), max_memory_usage_in_bytes=bootstrap_options. pantsd_max_memory_usage, ) store_gc_service = StoreGCService(legacy_graph_scheduler.scheduler) return PantsServices(services=tuple(service for service in ( fs_event_service, scheduler_service, store_gc_service, ) if service is not None), )
def create(cls, bootstrap_options=None, full_init=True): """ :param Options bootstrap_options: The bootstrap options, if available. :param bool full_init: Whether or not to fully initialize an engine et al for the purposes of spawning a new daemon. `full_init=False` is intended primarily for lightweight lifecycle checks (since there is a ~1s overhead to initialize the engine). See the impl of `maybe_launch` for an example of the intended usage. """ bootstrap_options = bootstrap_options or cls._parse_bootstrap_options() bootstrap_options_values = bootstrap_options.for_global_scope() # TODO: https://github.com/pantsbuild/pants/issues/3479 watchman = WatchmanLauncher.create(bootstrap_options_values).watchman native = None build_root = None services = None port_map = None if full_init: build_root = get_buildroot() native = Native.create(bootstrap_options_values) options_bootstrapper = OptionsBootstrapper() build_config = BuildConfigInitializer.get(options_bootstrapper) legacy_graph_scheduler = EngineInitializer.setup_legacy_graph(native, bootstrap_options_values, build_config) services, port_map = cls._setup_services( build_root, bootstrap_options_values, legacy_graph_scheduler, watchman ) return PantsDaemon( native=native, build_root=build_root, work_dir=bootstrap_options_values.pants_workdir, log_level=bootstrap_options_values.level.upper(), services=services, socket_map=port_map, metadata_base_dir=bootstrap_options_values.pants_subprocessdir, bootstrap_options=bootstrap_options )
def watchman_launcher(self): return WatchmanLauncher.create( self._bootstrap_options.for_global_scope())
def watchman_launcher(self): return WatchmanLauncher.create(self._bootstrap_options)
def watchman_launcher(self, cli_options=()): bootstrap_options = self.get_bootstrap_options(cli_options) return WatchmanLauncher.create(bootstrap_options)
def watchman_launcher(self): return WatchmanLauncher.create(self._bootstrap_options.for_global_scope())
def watchman_launcher(self, cli_options=()): options = ("--watchman-enable", *cli_options) bootstrap_options = self.get_bootstrap_options(options) return WatchmanLauncher.create(bootstrap_options)