diff --git a/README.md b/README.md index d7a7999..2c7c1f6 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Home Assistant related stuff: | `HA_SCREENSHOT_URL` | `/lovelace/screensaver?kiosk` | yes | yes | Relative URL to take screenshot of (btw, the `?kiosk` parameter hides the nav bar using the [kiosk mode](https://github.com/maykar/kiosk-mode) project) | | `HA_ACCESS_TOKEN` | `eyJ0...` | yes | no | Long-lived access token from Home Assistant, see [official docs](https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token) | | `LANGUAGE` | `en` | no | no | Language to set in browser and home assistant | -| `PREFERS_COLOR_SCHEME` | `light` | no | yes | Enable browser dark mode, use `light` or `dark`. | +| `PREFERS_COLOR_SCHEME` | `light` | no | yes | Enable browser dark mode, use `light` or `dark`. | | `CRON_JOB` | `* * * * *` | no | no | How often to take screenshot | | `RENDERING_TIMEOUT` | `10000` | no | no | Timeout of render process, helpful if your HASS instance might be down | | `RENDERING_DELAY` | `0` | no | yes | how long to wait between navigating to the page and taking the screenshot, in milliseconds | @@ -43,7 +43,7 @@ Home Assistant related stuff: | `DITHER` | `false` | no | yes | Apply a dither to the images. | | `REAL_TIME` | `false` | no | no | Disables cron and renders images as they are requests to save CPU | | `REAL_TIME_CACHE_SEC` | `60` | no | yes | How long to cache images for when `REAL_TIME` is set to true | -| `REMOVE_GAMMA` | `true` | no | no | Remove gamma correction from image. Computer images are normally gamma corrected since monitors expect gamma corrected data, however some E-Ink displays expect images not to have gamma correction. | +| `REMOVE_GAMMA` | `true` | no | no | Remove gamma correction from image. Computer images are normally gamma corrected since monitors expect gamma corrected data, however some E-Ink displays expect images not to have gamma correction. | | `MQTT_SERVER` | `` | no | no | MQTT hostname to report values to | | `MQTT_USERNAME` | `` | no | no | MQTT authentication username if required | | `MQTT_PASSWORD` | `` | no | no | MQTT authentication password if required | @@ -54,6 +54,12 @@ You can access these additional images by making GET Requests `http://localhost: You may also simply use the `docker-compose.yml` file inside this repository, configure everything in there and run `docker-compose up`. +### Other endpoints + +From time to time, you may need to restart the process. You can do this by sending a `GET` request to `/exit` endpoint. This will exit the process. Simply set your docker container to *restart: unless-stopped* to automatically restart it. + +`http://localhost:5000/exit` + ### Advanced configuration Some advanced variables for local usage which shouldn't be necessary when using Docker: diff --git a/docker-compose.yml b/docker-compose.yml index 1da0140..48f09ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,7 @@ services: - LANGUAGE=en - ROTATION=0 - SCALING=1 + restart: unless-stopped ports: - 5000:5000 volumes: diff --git a/index.js b/index.js index 08a1162..0a4bfba 100644 --- a/index.js +++ b/index.js @@ -102,7 +102,14 @@ var mqttClient = {}; const httpServer = http.createServer(async (request, response) => { // Parse the request - console.log(`recieved request from ${request.connection.remoteAddress} for ${request.url}`); + console.log(`received request from ${request.connection.remoteAddress} for ${request.url}`); + + // support to kill the process + if (request.url == '/exit') { + process.exit(1); + return; + } + const url = new URL(request.url, `http://${request.headers.host}`); // Check the page number const pageNumberStr = url.pathname;