Skip to content

Commit

Permalink
Make usage of pantsd imply usage of watchman. (pantsbuild#4512)
Browse files Browse the repository at this point in the history
### Problem

The pants daemon is only useful in the context of the `--fs-event-detection` flag, but usage of that flag is currently optional.

### Solution

Deprecate that flag, such that usage of `--enable-pantsd` implies `--fs-event-detection`.
  • Loading branch information
Stu Hood authored and thesamet committed May 9, 2017
1 parent 89928d1 commit ba1e67c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
3 changes: 0 additions & 3 deletions pants.daemon.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,3 @@

[GLOBAL]
enable_pantsd: True

[pantsd]
fs_event_detection: True
40 changes: 17 additions & 23 deletions src/python/pants/init/pants_daemon_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ def register_options(cls, register):
register('--log-dir', advanced=True, default=None,
help='The directory to log pantsd output to.')
register('--fs-event-detection', advanced=True, type=bool,
help='Whether or not to use filesystem event detection. Experimental.')
removal_version='1.5.0.dev0',
removal_hint='This option is now implied by `--enable-pantsd`.',
help='Whether or not to use filesystem event detection.')
register('--fs-event-workers', advanced=True, type=int, default=4,
help='The number of workers to use for the filesystem event service executor pool.'
' Experimental.')
help='The number of workers to use for the filesystem event service executor pool.')

@classmethod
def subsystem_dependencies(cls):
Expand All @@ -61,7 +62,6 @@ def create(self, engine_initializer=None):
log_level=options.level.upper(),
pailgun_host=options.pailgun_host,
pailgun_port=options.pailgun_port,
fs_event_enabled=options.fs_event_detection,
fs_event_workers=options.fs_event_workers,
pants_ignore_patterns=options.pants_ignore,
build_ignore_patterns=options.build_ignore,
Expand All @@ -76,7 +76,6 @@ def __init__(self,
log_level,
pailgun_host,
pailgun_port,
fs_event_enabled,
fs_event_workers,
pants_ignore_patterns,
build_ignore_patterns,
Expand All @@ -90,8 +89,6 @@ def __init__(self,
:param str log_level: The log level for pantsd logs (derived from the pants log level).
:param str pailgun_host: The bind address for the Pailgun server.
:param int pailgun_port: The bind port for the Pailgun server.
:param bool fs_event_enabled: Whether or not to enable fs event detection (Watchman) for graph
invalidation.
:param int fs_event_workers: The number of workers to use for processing the fs event queue.
:param list pants_ignore_patterns: A list of path ignore patterns for filesystem operations.
:param list build_ignore_patterns: A list of path ignore patterns for BUILD file parsing.
Expand All @@ -106,7 +103,6 @@ def __init__(self,
self._log_level = log_level
self._pailgun_host = pailgun_host
self._pailgun_port = pailgun_port
self._fs_event_enabled = fs_event_enabled
self._fs_event_workers = fs_event_workers
self._pants_ignore_patterns = pants_ignore_patterns
self._build_ignore_patterns = build_ignore_patterns
Expand Down Expand Up @@ -139,18 +135,17 @@ def _setup_services(self, watchman):

services = []
scheduler_service = None
if self._fs_event_enabled:
fs_event_service = FSEventService(watchman, self._build_root, self._fs_event_workers)

legacy_graph_helper = self._engine_initializer.setup_legacy_graph(
self._pants_ignore_patterns,
self._pants_workdir,
build_ignore_patterns=self._build_ignore_patterns,
exclude_target_regexps=self._exclude_target_regexp,
subproject_roots=self._subproject_roots,
)
scheduler_service = SchedulerService(fs_event_service, legacy_graph_helper)
services.extend((fs_event_service, scheduler_service))
fs_event_service = FSEventService(watchman, self._build_root, self._fs_event_workers)

legacy_graph_helper = self._engine_initializer.setup_legacy_graph(
self._pants_ignore_patterns,
self._pants_workdir,
build_ignore_patterns=self._build_ignore_patterns,
exclude_target_regexps=self._exclude_target_regexp,
subproject_roots=self._subproject_roots,
)
scheduler_service = SchedulerService(fs_event_service, legacy_graph_helper)
services.extend((fs_event_service, scheduler_service))

pailgun_service = PailgunService(bind_addr=(self._pailgun_host, self._pailgun_port),
exiter_class=DaemonExiter,
Expand All @@ -167,7 +162,7 @@ def _setup_services(self, watchman):

def _launch_pantsd(self):
# Launch Watchman (if so configured).
watchman = self.watchman_launcher.maybe_launch() if self._fs_event_enabled else None
watchman = self.watchman_launcher.maybe_launch()

# Initialize pantsd services.
services, port_map = self._setup_services(watchman)
Expand All @@ -192,5 +187,4 @@ def maybe_launch(self):

def terminate(self):
self.pantsd.terminate()
if self._fs_event_enabled:
self.watchman_launcher.terminate()
self.watchman_launcher.terminate()
7 changes: 3 additions & 4 deletions tests/python/pants_test/pantsd/test_pantsd_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ def test_pantsd_run(self):
print(line)

def test_pantsd_run_with_watchman(self):
config = {'pantsd': {'fs_event_detection': True},
# The absolute paths in CI can exceed the UNIX socket path limitation
# (>104-108 characters), so we override that here with a shorter path.
'watchman': {'socket_path': '/tmp/watchman.{}.sock'.format(os.getpid())}}
# The absolute paths in CI can exceed the UNIX socket path limitation
# (>104-108 characters), so we override that here with a shorter path.
config = {'watchman': {'socket_path': '/tmp/watchman.{}.sock'.format(os.getpid())}}

with self.pantsd_test_context(config) as (workdir, pantsd_config, checker):
print('log: {}/pantsd/pantsd.log'.format(workdir))
Expand Down

0 comments on commit ba1e67c

Please sign in to comment.