public static void sendSignalToProcess(long lpid, int signum) throws IOException { String pid = Long.toString(lpid); try { if (Utils.isOnWindows()) { if (signum == SIGKILL) { execCommand("taskkill", "/f", "/pid", pid); } else { execCommand("taskkill", "/pid", pid); } } else { execCommand("kill", "-" + signum, pid); } } catch (ExecuteException e) { LOG.info("Error when trying to kill {}. Process is probably already dead.", pid); } catch (IOException e) { LOG.info("IOException Error when trying to kill {}.", pid); throw e; } }
public static void main(String[] args) throws Exception { if (args.length <= 1) { LOG.error("Arguments should be of the form: <path_to_jar> [argument...]"); System.exit(-1); } Map<String,Object> conf = ConfigUtils.readStormConfig(); try (NimbusClient client = NimbusClient.getConfiguredClient(conf)) { NimbusSummary ns = client.getClient().getLeader(); String host = ns.get_host(); int port = ns.get_port(); String jarPath = StormSubmitter.submitJar(conf, args[0]); String[] newArgs = (String[]) ArrayUtils.addAll(Arrays.copyOfRange(args, 1, args.length), new String[]{host, String.valueOf(port), jarPath}); ServerUtils.execCommand(newArgs); } } }