Skip to content

Commit 7d21ea7

Browse files
committed
Activate logging for backend service using winston for observability
Make healthcheck work
1 parent 8daeaf7 commit 7d21ea7

File tree

12 files changed

+539
-37
lines changed

12 files changed

+539
-37
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ In order do as follows
99
1. Copy `dbpass.txt.example` to `dbpass.txt` and set a password
1010
2. Copy `password-file.txt.example` to `password-file.txt` and set the same password
1111

12+
Alternatively, set `POSTGRES_HOST_AUTH_METHOD=trust` and pass it to docker compose (No authenthication, this is done on debug mode)
1213

1314
### Local
1415

1516
1. Install **node 22**
1617
2. Run `npm install`
1718

18-
1919
## Local Development
2020

2121
### Build
@@ -32,13 +32,13 @@ npm run build -ws
3232
npm run test -ws
3333
```
3434

35-
### Prepare database
35+
### Prepare database for local development
3636

3737
```bash
3838
# at a separate terminal run this and keep running
3939
docker compose -f compose.yaml -f compose.debug.yaml up db
4040
# In a separate terminal, (I believe postgresql does this automatically)
41-
npm run db:prepare -w backend
41+
# npm run db:prepare -w backend
4242
```
4343

4444
### Launch

compose.debug.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# TODO: Make this auto-reloadable and expose debug ports to the outside world
22
services:
33
frontend: {}
4-
backend: {}
4+
backend:
5+
ports:
6+
# Avoid conflicts with local development
7+
- 3003:3000
58
db:
69
environment:
710
POSTGRES_HOST_AUTH_METHOD: trust

compose.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,23 @@ services:
3232
PGUSER: postgres
3333
PGPORT: 5432
3434
PGDATABASE: taskdb
35-
ports:
36-
- 3000:3000
3735
depends_on:
3836
db:
3937
condition: service_healthy
4038
secrets:
4139
- db-password
4240
healthcheck:
4341
test:
44-
# node
45-
[
46-
'CMD',
47-
'wget --no-verbose --server-response --tries=1
48-
--spider http://localhost:3000/v1/health',
49-
]
42+
- CMD
43+
- /usr/bin/wget
44+
- --no-verbose
45+
- --server-response
46+
- --tries=1
47+
- --spider
48+
- http://localhost:3000/health
5049
interval: 5s
50+
start_interval: 1s
51+
start_period: 1s
5152
timeout: 1s
5253
retries: 3
5354
db:
@@ -62,14 +63,15 @@ services:
6263
environment:
6364
POSTGRES_DB: taskdb
6465
POSTGRES_PASSWORD_FILE: /run/secrets/db-password
66+
POSTGRES_HOST_AUTH_METHOD: $POSTGRES_HOST_AUTH_METHOD
6567
expose:
6668
- 5432
67-
ports:
68-
- 5432:5432
6969

7070
healthcheck:
7171
test: ['CMD', 'pg_isready']
7272
interval: 5s
73+
start_interval: 1s
74+
start_period: 1s
7375
timeout: 1s
7476
retries: 3
7577

0 commit comments

Comments
 (0)