Skip to content

Commit

Permalink
[pantsd] Bump to watchman 4.9.0-pants1. (#5386)
Browse files Browse the repository at this point in the history
This PR consumes the hotfixed watchman binaries and plumbs use of their updated options so that multiple pants-spawned watchmen may now co-exist.

Fixes #5224
  • Loading branch information
kwlzn authored and stuhood committed Jan 25, 2018
1 parent 8dd6255 commit 50bf568
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/python/pants/option/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def register_bootstrap_options(cls, register):
help='The number of workers to use for the filesystem event service executor pool.')

# Watchman options.
register('--watchman-version', advanced=True, default='4.9.0', help='Watchman version.')
register('--watchman-version', advanced=True, default='4.9.0-pants1', help='Watchman version.')
register('--watchman-supportdir', advanced=True, default='bin/watchman',
help='Find watchman binaries under this dir. Used as part of the path to lookup '
'the binary with --binary-util-baseurls and --pants-bootstrapdir.')
Expand Down
6 changes: 5 additions & 1 deletion src/python/pants/pantsd/watchman.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, watchman_path, metadata_base_dir, log_level='1', startup_time

self._state_file = os.path.join(self._watchman_work_dir, '{}.state'.format(self.name))
self._log_file = os.path.join(self._watchman_work_dir, '{}.log'.format(self.name))
self._pid_file = os.path.join(self._watchman_work_dir, '{}.pid'.format(self.name))
self._sock_file = socket_path_override or os.path.join(self._watchman_work_dir,
'{}.sock'.format(self.name))

Expand Down Expand Up @@ -83,10 +84,12 @@ def _maybe_init_metadata(self):
# Initialize watchman with an empty, but valid statefile so it doesn't complain on startup.
safe_file_dump(self._state_file, '{}')

def _construct_cmd(self, cmd_parts, state_file, sock_file, log_file, log_level):
def _construct_cmd(self, cmd_parts, state_file, sock_file, pid_file, log_file, log_level):
return [part for part in cmd_parts] + ['--no-save-state',
'--no-site-spawner',
'--statefile={}'.format(state_file),
'--sockname={}'.format(sock_file),
'--pidfile={}'.format(pid_file),
'--logfile={}'.format(log_file),
'--log-level', log_level]

Expand All @@ -111,6 +114,7 @@ def launch(self):
cmd = self._construct_cmd((self._watchman_path, 'get-pid'),
state_file=self._state_file,
sock_file=self._sock_file,
pid_file=self._pid_file,
log_file=self._log_file,
log_level=str(self._log_level))
self._logger.debug('watchman cmd is: {}'.format(' '.join(cmd)))
Expand Down
3 changes: 3 additions & 0 deletions tests/python/pants_test/pantsd/test_watchman.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,18 @@ def test_construct_cmd(self):
output = self.watchman._construct_cmd(['cmd', 'parts', 'etc'],
'state_file',
'sock_file',
'pid_file',
'log_file',
'log_level')

self.assertEquals(output, ['cmd',
'parts',
'etc',
'--no-save-state',
'--no-site-spawner',
'--statefile=state_file',
'--sockname=sock_file',
'--pidfile=pid_file',
'--logfile=log_file',
'--log-level',
'log_level'])
Expand Down

0 comments on commit 50bf568

Please sign in to comment.