Configure Nightwatch on Cloud
1
Install Nightwatch package
Install the Laravel Nightwatch package in your application locally using Composer:
Run
composer require laravel/nightwatch on your local machine to update your composer.json and composer.lock files before deploying.2
Add your Nightwatch token
Add your Nightwatch environment’s
NIGHTWATCH_TOKEN to your .env file:3
Configure the agent as a background process
To ensure the Nightwatch agent is always running and sending data, configure it as a background process in your Cloud environment:


- Go to your App cluster in the Cloud dashboard.

Select the App cluster
- Click New background process.

Select “New Background Process”
- Choose Custom worker.

Add a custom worker that runs the `nightwatch:agent` command
- Enter the following command:
- Save your changes and redeploy your application.
4
Monitor the agent
To check the health of the running agent, use the following command:The
nightwatch:status command will exit with a non-zero status code if there is an error. This command will ensure the agent is able to accept connections and send data to Nightwatch.Use Cloud and Nightwatch logs
To send your logs to both Laravel Cloud Logs and Nightwatch, use Laravel’s log stacks feature. Update your.env file as shown below to enable logging to both services:

