]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.server/src/org/simantics/district/maps/server/TileserverMapnik.java
Make background map preference changes apply immediately
[simantics/district.git] / org.simantics.maps.server / src / org / simantics / district / maps / server / TileserverMapnik.java
index dbe525725dff6d6bc3fa9ef456b3ab8a023011bd..ef17ee06829db70a30a5c2ad45c94ab631345e68 100644 (file)
@@ -1,13 +1,11 @@
 package org.simantics.district.maps.server;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.nio.file.StandardOpenOption;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -22,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;
@@ -37,7 +36,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class TileserverMapnik {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(TileserverMapnik.class);
-    private static final String[] ADDITIONAL_DEPENDENCIES = new String[] { "tilelive-vector@3.9.4", "tilelive-tmstyle@0.6.0" };
     
     private SystemProcess process;
     private Path serverRoot;
@@ -61,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
@@ -173,7 +177,8 @@ public class TileserverMapnik {
 //    }
 
     
-    private Path tileserverMapnikRoot() {
+    @SuppressWarnings("unused")
+       private Path tileserverMapnikRoot() {
         return serverRoot.resolve("tileserver-mapnik").toAbsolutePath();
     }
     
@@ -185,7 +190,8 @@ public class TileserverMapnik {
         return serverRoot.resolve("dist/share/icu").toAbsolutePath();
     }
     
-    private Path getTessera() {
+    @SuppressWarnings("unused")
+       private Path getTessera() {
         return serverRoot.resolve("tileserver-mapnik/bin/tessera.js").toAbsolutePath();
     }
     
@@ -244,6 +250,7 @@ public class TileserverMapnik {
         return getDataDirectory().resolve(MapsServerPreferences.currentMBTiles());
     }
     
+    @SuppressWarnings("unchecked")
     public void checkTm2Styles() {
         Path tm2 = getStyleDirectory();
         try (DirectoryStream<Path> stream = Files.newDirectoryStream(tm2)) {