Skip to content

Commit 096b1ba

Browse files
Add Nightwatch health check script (#572)
* Add Nightwatch health check script * Add documentation for Laravel Nightwatch --------- Co-authored-by: Jay Rogers <3174134+jaydrogers@users.noreply.github.com> Co-authored-by: Jay Rogers <jaydrogers@users.noreply.serversideup.net>
1 parent 595c3b7 commit 096b1ba

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
head.title: 'Laravel Nightwatch with Docker - Docker PHP - Server Side Up'
3+
description: 'Learn how to configure Laravel Nightwatch with Docker.'
4+
layout: docs
5+
title: Nightwatch
6+
---
7+
8+
## Laravel Nightwatch with Docker
9+
Run Laravel Nightwatch by passing the Artisan command as the container's command. Nightwatch is Laravel's observability platform for monitoring application performance, errors, and queries in real-time.
10+
11+
::note
12+
Before using Nightwatch with Docker, follow the [Laravel Nightwatch setup instructions](https://nightwatch.laravel.com/docs/start-guide) to install and configure the Nightwatch package in your Laravel application.
13+
::
14+
15+
## Docker Compose example
16+
17+
This example runs Nightwatch as a separate container using the same image as your web service.
18+
19+
**Key points:**
20+
- Use the same image for both your web and Nightwatch services
21+
- Set `SIGTERM` as the stop signal for graceful shutdown (especially for `fpm-apache` and `fpm-nginx`)
22+
- Include a health check to monitor Nightwatch status
23+
24+
```yml [compose.yml]
25+
services:
26+
php:
27+
image: my/laravel-app
28+
29+
nightwatch:
30+
image: my/laravel-app
31+
command: ["php", "/var/www/html/artisan", "nightwatch:agent"]
32+
stop_signal: SIGTERM
33+
healthcheck:
34+
test: ["CMD", "healthcheck-nightwatch"]
35+
start_period: 10s
36+
```
37+
38+
## How the health check works
39+
40+
The `healthcheck-nightwatch` command runs `php artisan nightwatch:status` to verify that the Nightwatch agent is running and connected. Docker uses this to determine container health and can automatically restart unhealthy containers.
41+
42+
## Advanced configuration
43+
44+
**Graceful shutdown:** The `SIGTERM` signal ensures the Nightwatch agent finishes processing current events before stopping. This is especially important for `fpm-apache` and `fpm-nginx` images.
45+
46+
::tip
47+
**Multiple processes in one container:** If you're running `fpm-nginx` or `fpm-apache` and you'd like to have everything in a single container, you can [write your own S6 Overlay service script](https://github.com/just-containers/s6-overlay/tree/master#writing-a-service-script){target="_blank"} to properly manage multiple processes in a single container. Learn more about about this in our [Using S6 Overlay guide](/docs/guide/using-s6-overlay).
48+
::
49+
50+
## Learn More
51+
- [Laravel Nightwatch Documentation](https://nightwatch.laravel.com/docs/start-guide)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
php "${APP_BASE_DIR}/artisan" nightwatch:status

0 commit comments

Comments
 (0)