From: jsimomaa Date: Sun, 24 Nov 2019 14:34:42 +0000 (+0200) Subject: Do not fail mapserver startup if destroying existing process fails X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F3606%2F1;p=simantics%2Fdistrict.git Do not fail mapserver startup if destroying existing process fails gitlab #71 Change-Id: I07084ee20b64c896afc1c0addc70d4c5355ed69c --- diff --git a/org.simantics.maps.server/src/org/simantics/district/maps/server/TileserverMapnik.java b/org.simantics.maps.server/src/org/simantics/district/maps/server/TileserverMapnik.java index 3ba5157d..ef17ee06 100644 --- a/org.simantics.maps.server/src/org/simantics/district/maps/server/TileserverMapnik.java +++ b/org.simantics.maps.server/src/org/simantics/district/maps/server/TileserverMapnik.java @@ -20,6 +20,7 @@ import org.simantics.district.maps.server.prefs.MapsServerPreferences; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.Yaml; +import org.zeroturnaround.exec.InvalidExitValueException; import org.zeroturnaround.exec.ProcessExecutor; import org.zeroturnaround.exec.StartedProcess; import org.zeroturnaround.exec.stream.slf4j.Slf4jDebugOutputStream; @@ -58,7 +59,13 @@ public class TileserverMapnik { if (Files.exists(getPid())) { String pid = new String(Files.readAllBytes(getPid())); PidProcess pr = Processes.newPidProcess(Integer.parseInt(pid)); - pr.destroyForcefully(); + try { + pr.destroyForcefully(); + } catch (InvalidExitValueException e) { + // ignore, + } catch (Exception e) { + LOGGER.error("Could not destroy process with pid {}", pid, e); + } } // check that npm dependencies are satisfied