From 8974786ac1cb6bed83d084f52e21981e50c63e74 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Sun, 24 Nov 2019 16:34:42 +0200 Subject: [PATCH] Do not fail mapserver startup if destroying existing process fails gitlab #71 Change-Id: I07084ee20b64c896afc1c0addc70d4c5355ed69c (cherry picked from commit 6b3b840535b8feb1b67a7ae6bacaaa2c961a4064) --- .../simantics/district/maps/server/TileserverMapnik.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.47.1