Starts up an impalad with the specified command line arguments. args must be a list of strings. An optional build_type parameter can be passed to determine the build type to use for the impalad instance. Any values in the env_vars override environment variables inherited from this process. If
(daemon_binary, args, build_type="latest", env_vars={}, output_file=None)
| 809 | |
| 810 | |
| 811 | def run_daemon(daemon_binary, args, build_type="latest", env_vars={}, output_file=None): |
| 812 | """Starts up an impalad with the specified command line arguments. args must be a list |
| 813 | of strings. An optional build_type parameter can be passed to determine the build type |
| 814 | to use for the impalad instance. Any values in the env_vars override environment |
| 815 | variables inherited from this process. If output_file is specified, stdout and stderr |
| 816 | are redirected to that file. |
| 817 | """ |
| 818 | bin_path = os.path.join(IMPALA_HOME, "be", "build", build_type, "service", |
| 819 | daemon_binary) |
| 820 | redirect = "" |
| 821 | if output_file is not None: |
| 822 | redirect = "1>{0} 2>&1".format(output_file) |
| 823 | cmd = [START_DAEMON_PATH, bin_path] + args |
| 824 | # Use os.system() to start 'cmd' in the background via a shell so its parent will be |
| 825 | # init after the shell exits. Otherwise, the parent of 'cmd' will be py.test and we |
| 826 | # cannot cleanly kill it until py.test exits. In theory, Popen(shell=True) should |
| 827 | # achieve the same thing but it doesn't work on some platforms for some reasons. |
| 828 | sys_cmd = ("{set_cmds} {cmd} {redirect} &".format( |
| 829 | set_cmds=''.join(["export {0}={1};".format(k, shlex.quote(v)) |
| 830 | for k, v in env_vars.items()]), |
| 831 | cmd=' '.join([shlex.quote(tok) for tok in cmd]), |
| 832 | redirect=redirect)) |
| 833 | os.system(sys_cmd) |
| 834 | |
| 835 | |
| 836 | def get_container_info(container_id): |