Use chokidar instead of node-watch to poll the files (required for docker)
This commit is contained in:
parent
aa933e5154
commit
ea89d11021
4 changed files with 21 additions and 13 deletions
|
@ -1,6 +1,8 @@
|
||||||
FROM node:10-stretch
|
FROM node:10-stretch
|
||||||
|
|
||||||
ENV NODE_ENV="production"
|
ENV NODE_ENV="production"
|
||||||
|
ENV CHOKIDAR_USEPOLLING=1
|
||||||
|
ENV CHOKIDAR_INTERVAL=500
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
FROM node:10-stretch
|
FROM node:10-stretch
|
||||||
|
|
||||||
ENV NODE_ENV="production"
|
ENV NODE_ENV="production"
|
||||||
|
ENV CHOKIDAR_USEPOLLING=1
|
||||||
|
ENV CHOKIDAR_INTERVAL=500
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
"@mapbox/vector-tile": "1.3.1",
|
"@mapbox/vector-tile": "1.3.1",
|
||||||
"advanced-pool": "0.3.3",
|
"advanced-pool": "0.3.3",
|
||||||
"canvas": "2.6.1",
|
"canvas": "2.6.1",
|
||||||
|
"chokidar": "3.3.1",
|
||||||
"clone": "2.1.2",
|
"clone": "2.1.2",
|
||||||
"color": "3.1.2",
|
"color": "3.1.2",
|
||||||
"commander": "4.0.1",
|
"commander": "4.0.1",
|
||||||
|
@ -34,7 +35,6 @@
|
||||||
"handlebars": "4.5.3",
|
"handlebars": "4.5.3",
|
||||||
"http-shutdown": "1.2.1",
|
"http-shutdown": "1.2.1",
|
||||||
"morgan": "1.9.1",
|
"morgan": "1.9.1",
|
||||||
"node-watch": "0.6.3",
|
|
||||||
"pbf": "3.2.1",
|
"pbf": "3.2.1",
|
||||||
"proj4": "2.6.0",
|
"proj4": "2.6.0",
|
||||||
"request": "2.88.0",
|
"request": "2.88.0",
|
||||||
|
|
|
@ -7,6 +7,7 @@ process.env.UV_THREADPOOL_SIZE =
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
const chokidar = require('chokidar');
|
||||||
const clone = require('clone');
|
const clone = require('clone');
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
const enableShutdown = require('http-shutdown');
|
const enableShutdown = require('http-shutdown');
|
||||||
|
@ -14,7 +15,6 @@ const express = require('express');
|
||||||
const handlebars = require('handlebars');
|
const handlebars = require('handlebars');
|
||||||
const mercator = new (require('@mapbox/sphericalmercator'))();
|
const mercator = new (require('@mapbox/sphericalmercator'))();
|
||||||
const morgan = require('morgan');
|
const morgan = require('morgan');
|
||||||
const watch = require('node-watch');
|
|
||||||
|
|
||||||
const packageJson = require('../package');
|
const packageJson = require('../package');
|
||||||
const serve_font = require('./serve_font');
|
const serve_font = require('./serve_font');
|
||||||
|
@ -217,21 +217,25 @@ function start(opts) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(options.paths.styles,
|
const watcher = chokidar.watch(path.join(options.paths.styles, '*.json'),
|
||||||
{ persistent: false, filter: /\.json$/ },
|
{
|
||||||
|
});
|
||||||
|
watcher.on('all',
|
||||||
(eventType, filename) => {
|
(eventType, filename) => {
|
||||||
|
if (filename) {
|
||||||
let id = path.basename(filename, '.json');
|
let id = path.basename(filename, '.json');
|
||||||
console.log(`Style "${id}" changed, updating...`);
|
console.log(`Style "${id}" changed, updating...`);
|
||||||
|
|
||||||
serve_style.remove(serving.styles, id);
|
serve_style.remove(serving.styles, id);
|
||||||
serve_rendered.remove(serving.rendered, id);
|
serve_rendered.remove(serving.rendered, id);
|
||||||
|
|
||||||
if (eventType == "update") {
|
if (eventType == "add" || eventType == "change") {
|
||||||
let item = {
|
let item = {
|
||||||
style: filename
|
style: filename
|
||||||
};
|
};
|
||||||
addStyle(id, item, false, false);
|
addStyle(id, item, false, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue