/** * Launch the worker process (non-blocking). * * @param command the command to run * @param env the environment to run the command * @param processExitCallback a callback for when the process exits * @param logPrefix the prefix to include in the logs * @param targetDir the working directory to run the command in * @return true if it ran successfully, else false * * @throws IOException on any error */ protected void launchWorkerProcess(List<String> command, Map<String, String> env, String logPrefix, ExitCodeCallback processExitCallback, File targetDir) throws IOException { if (_resourceIsolationManager != null) { command = _resourceIsolationManager.getLaunchCommand(_workerId, command); } ClientSupervisorUtils.launchProcess(command, env, logPrefix, processExitCallback, targetDir); }
/** * Run the given command for profiling. * * @param command the command to run * @param env the environment to run the command * @param logPrefix the prefix to include in the logs * @param targetDir the working directory to run the command in * @return true if it ran successfully, else false * * @throws IOException on any error * @throws InterruptedException if interrupted wile waiting for the process to exit. */ protected boolean runProfilingCommand(List<String> command, Map<String, String> env, String logPrefix, File targetDir) throws IOException, InterruptedException { _type.assertFull(); Process p = ClientSupervisorUtils.launchProcess(command, env, logPrefix, null, targetDir); int ret = p.waitFor(); return ret == 0; }
static Process processLauncher(Map<String, Object> conf, String user, List<String> commandPrefix, List<String> args, Map<String, String> environment, final String logPreFix, final ExitCodeCallback exitCodeCallback, File dir) throws IOException { if (StringUtils.isBlank(user)) { throw new IllegalArgumentException("User cannot be blank when calling processLauncher."); } String wlinitial = (String) (conf.get(Config.SUPERVISOR_WORKER_LAUNCHER)); String stormHome = ConfigUtils.concatIfNotNull(System.getProperty(ConfigUtils.STORM_HOME)); String wl; if (StringUtils.isNotBlank(wlinitial)) { wl = wlinitial; } else { wl = stormHome + "/bin/worker-launcher"; } List<String> commands = new ArrayList<>(); if (commandPrefix != null) { commands.addAll(commandPrefix); } commands.add(wl); commands.add(user); commands.addAll(args); LOG.info("Running as user: {} command: {}", user, commands); return launchProcess(commands, environment, logPreFix, exitCodeCallback, dir); }