Skip to content

Commit

Permalink
Merge pull request #93 from cupcakearmy/feat/92-health-check
Browse files Browse the repository at this point in the history
Feat/92 health check
  • Loading branch information
cupcakearmy committed Jun 23, 2023
2 parents c9e5de0 + e2711cc commit c46f80a
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 191 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.1] - 2023-06-23

### Added

- #92: Endpoint (`/api/live/`) for checking health status.

## [2.3.0] - 2023-05-30

### Added
Expand Down
108 changes: 104 additions & 4 deletions Cryptgeon.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "52d9e661-2d99-47f8-b09a-40b6a1c0b364",
"_postman_id": "3aaeac19-4eac-4911-b3c8-912b17a48634",
"name": "Cryptgeon",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
Expand Down Expand Up @@ -137,7 +137,7 @@
}
],
"cookie": [],
"body": null
"body": ""
}
]
},
Expand Down Expand Up @@ -479,7 +479,7 @@
}
],
"cookie": [],
"body": null
"body": ""
}
]
}
Expand All @@ -489,7 +489,7 @@
"name": "Status",
"item": [
{
"name": "Get",
"name": "Get server status",
"request": {
"method": "GET",
"header": [],
Expand Down Expand Up @@ -554,6 +554,106 @@
"body": "{\n \"version\": \"2.3.0-beta.4\",\n \"max_size\": 10485760,\n \"max_views\": 100,\n \"max_expiration\": 360,\n \"allow_advanced\": true,\n \"theme_image\": \"\",\n \"theme_text\": \"\",\n \"theme_page_title\": \"\",\n \"theme_favicon\": \"\"\n}"
}
]
},
{
"name": "Health Check",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE}}/live/",
"host": [
"{{BASE}}"
],
"path": [
"live",
""
]
},
"description": "Return `200` for healthy service. `503` if service is unavailable."
},
"response": [
{
"name": "Healthy",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE}}/live/",
"host": [
"{{BASE}}"
],
"path": [
"live",
""
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "plain",
"header": [
{
"key": "transfer-encoding",
"value": "chunked"
},
{
"key": "vary",
"value": "accept-encoding"
},
{
"key": "content-encoding",
"value": "gzip"
},
{
"key": "date",
"value": "Thu, 22 Jun 2023 20:17:58 GMT"
}
],
"cookie": [],
"body": null
},
{
"name": "Service Unavilable",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "{{BASE}}/live/",
"host": [
"{{BASE}}"
],
"path": [
"live",
""
]
}
},
"status": "Service Unavailable",
"code": 503,
"_postman_previewlanguage": "plain",
"header": [
{
"key": "transfer-encoding",
"value": "chunked"
},
{
"key": "content-encoding",
"value": "gzip"
},
{
"key": "vary",
"value": "accept-encoding"
},
{
"key": "date",
"value": "Thu, 22 Jun 2023 20:18:55 GMT"
}
],
"cookie": [],
"body": null
}
]
}
]
}
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RUN cargo build --release
# RUNNER
FROM alpine
WORKDIR /app
RUN apk add --no-cache curl
COPY --from=backend /tmp/target/release/cryptgeon .
COPY --from=client /tmp/packages/frontend/build ./frontend
ENV FRONTEND_PATH="./frontend"
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ of the notes even if it tried to.

## Deployment

ℹ️ `https` is required otherwise browsers will not support the cryptographic functions.
> ℹ️ `https` is required otherwise browsers will not support the cryptographic functions.
> ℹ️ There is a health endpoint available at `/api/health/`. It returns either 200 or 503.
### Docker

Expand All @@ -94,7 +96,7 @@ services:
image: redis:7-alpine
# Set a size limit. See link below on how to customise.
# https://redis.io/docs/manual/eviction/
command: redis-server --maxmemory 1gb --maxmemory-policy allkeys-lru
# command: redis-server --maxmemory 1gb --maxmemory-policy allkeys-lru

app:
image: cupcakearmy/cryptgeon:latest
Expand All @@ -105,6 +107,14 @@ services:
SIZE_LIMIT: 4 MiB
ports:
- 80:8000

# Optional health checks
# healthcheck:
# test: ["CMD", "curl", "--fail", "http://127.0.0.1:8000/api/live/"]
# interval: 1m
# timeout: 3s
# retries: 2
# start_period: 5s
```

### NGINX Proxy
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ services:
- redis
ports:
- 1234:8000

healthcheck:
test: ["CMD", "curl", "--fail", "http://127.0.0.1:8000/api/live/"]
interval: 1m
timeout: 3s
retries: 2
start_period: 5s
8 changes: 8 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ services:
SIZE_LIMIT: 4 MiB
ports:
- 80:8000

# Optional health checks
# healthcheck:
# test: ["CMD", "curl", "--fail", "http://127.0.0.1:8000/api/live/"]
# interval: 1m
# timeout: 3s
# retries: 2
# start_period: 5s
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packageManager": "pnpm@8.5.1",
"packageManager": "pnpm@8.6.3",
"scripts": {
"dev:docker": "docker-compose -f docker-compose.dev.yaml up redis",
"dev:packages": "pnpm --parallel run dev",
Expand Down
Loading

0 comments on commit c46f80a

Please sign in to comment.