Skip to content

Commit

Permalink
Merge pull request #18 from dbochicchio/main
Browse files Browse the repository at this point in the history
New endpoint to exit the process
  • Loading branch information
lanrat authored May 16, 2024
2 parents 2e8e45e + 1c131d9 commit 8293194
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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 |
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
- LANGUAGE=en
- ROTATION=0
- SCALING=1
restart: unless-stopped
ports:
- 5000:5000
volumes:
Expand Down
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8293194

Please sign in to comment.