Skip to content

Commit 82dbf6c

Browse files
committed
feat: added nightwatch monitoring
1 parent 58e10db commit 82dbf6c

File tree

5 files changed

+148
-19
lines changed

5 files changed

+148
-19
lines changed

.env.prod.example

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ APP_URL=http://localhost
66

77
BCRYPT_ROUNDS=12
88

9-
LOG_LEVEL=debug
10-
LOG_CHANNEL=errorlog
9+
LOG_LEVEL=warning
10+
LOG_CHANNEL=stack
11+
LOG_STACK=errorlog,nightwatch
1112
LOG_DEPRECATIONS_CHANNEL=errorlog
1213

14+
NIGHTWATCH_TOKEN=
15+
NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1
16+
1317
DB_CONNECTION=sqlite
1418
DB_DATABASE=/var/www/html/storage/database.sqlite
1519

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
"ext-hash": "*",
2121
"ext-mbstring": "*",
2222
"ext-openssl": "*",
23+
"ext-pcntl": "*",
2324
"ext-pcre": "*",
2425
"ext-pdo": "*",
2526
"ext-session": "*",
2627
"ext-tokenizer": "*",
2728
"ext-xml": "*",
28-
"ext-pcntl": "*",
2929
"laravel/framework": "^12.0",
30+
"laravel/nightwatch": "^1.12",
3031
"laravel/tinker": "^2.10.1",
3132
"league/flysystem-aws-s3-v3": "^3.0"
3233
},

composer.lock

Lines changed: 89 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

containers/php/entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ elif [ "$1" = "worker" ]; then
2828
php artisan optimize
2929
fi
3030
set -- su -s /bin/sh -c "php artisan queue:work --tries=3 --timeout=1800" www-data
31+
elif [ "$1" = "nightwatch" ]; then
32+
wait-for "${PHP_HOST:?Missing PHP_HOST}:${PHP_PORT:?Missing PHP_PORT}" -t 60
33+
if [ "$APP_ENV" != "local" ]; then
34+
php artisan optimize
35+
fi
36+
set -- su -s /bin/sh -c "php artisan nightwatch:agent --listen-on 0.0.0.0:2407" www-data
3137
fi
3238

3339
exec "$@"

docker-compose.yml

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
x-app: &app
2+
pull_policy: never
3+
build:
4+
dockerfile: containers/php/Dockerfile
5+
target: development
6+
args:
7+
UID: ${UID:-1000}
8+
GID: ${GID:-1000}
9+
restart: unless-stopped
10+
extra_hosts:
11+
- "host.docker.internal:host-gateway"
12+
volumes:
13+
- /etc/localtime:/etc/localtime:ro
14+
- .:/var/www/html
15+
116
services:
217
nginx:
318
pull_policy: never
@@ -10,16 +25,33 @@ services:
1025
FPM_HOST: php
1126
FPM_PORT: 9000
1227
php:
13-
pull_policy: never
14-
build:
15-
dockerfile: containers/php/Dockerfile
16-
target: development
17-
args:
18-
UID: ${UID:-1000}
19-
GID: ${GID:-1000}
20-
restart: unless-stopped
21-
extra_hosts:
22-
- "host.docker.internal:host-gateway"
23-
volumes:
24-
- /etc/localtime:/etc/localtime:ro
25-
- .:/var/www/html
28+
<<: *app
29+
environment:
30+
NIGHTWATCH_INGEST_URI: nightwatch-agent:2407
31+
scheduler:
32+
<<: *app
33+
user: root
34+
command: scheduler
35+
environment:
36+
PHP_HOST: php
37+
PHP_PORT: 9000
38+
worker:
39+
<<: *app
40+
user: root
41+
command: worker
42+
environment:
43+
PHP_HOST: php
44+
PHP_PORT: 9000
45+
nightwatch-agent:
46+
<<: *app
47+
user: root
48+
command: nightwatch
49+
environment:
50+
PHP_HOST: php
51+
PHP_PORT: 9000
52+
healthcheck:
53+
test: php artisan nightwatch:status
54+
interval: 30s
55+
timeout: 5s
56+
retries: 3
57+
start_period: 5s

0 commit comments

Comments
 (0)