'Test that a service correctly (re)starts on receiving SIGHUP.
1. Start a service with a given number of workers.
2. Send SIGHUP to the service.
3. Wait for workers (if any) to (re)start.'

def _test_restart_service_on_sighup(self, service, workers=1):

    self._start_server(callback=service, workers=workers)
    os.kill(self.service_pid, signal.SIGHUP)
    expected_msg = ((FAKE_START_MSG * workers) * 2)
    expected_size = len(expected_msg)
    condition = (lambda : (os.path.isfile(self.temp_file) and (os.stat(self.temp_file).st_size == expected_size)))
    utils.wait_until_true(condition, timeout=5, sleep=0.1, exception=RuntimeError(('Timed    out    waiting    for    file    %(filename)s    to    be    created    and    its    size    become    equal    to    %(size)s.' % {'filename': self.temp_file, 'size': expected_size})))
    with open(self.temp_file, 'rb') as f:
        res = f.readline()
        self.assertEqual(expected_msg, res)
