Skip to content
spectivis.com

Noctora

Running the agent

Keep php artisan nightwatch:agent running under Supervisor, systemd, Laravel Forge, Docker or another platform.

The agent, php artisan nightwatch:agent, has to run all the time. Your app doesn’t talk to Noctora directly. It hands each request’s data to the agent over a local connection, and the agent sends it on. If the agent stops, monitoring stops.

Restart the agent after you change its NIGHTWATCH_ settings or update laravel/nightwatch, since it keeps running with what it started with.

Save this as /etc/supervisor/conf.d/nightwatch-agent.conf:

[program:nightwatch-agent]
command=php /path/to/your-app/artisan nightwatch:agent
directory=/path/to/your-app
user=www-data
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=/path/to/your-app/storage/logs/nightwatch-agent.log

Replace /path/to/your-app and www-data with your app’s path and user, then load it:

Terminal window
sudo supervisorctl reread && sudo supervisorctl update
sudo supervisorctl status nightwatch-agent

The agent writes to storage/logs/nightwatch-agent.log. If it can’t sign in, the log says why. Restart it with sudo supervisorctl restart nightwatch-agent.

Save this as /etc/systemd/system/nightwatch-agent.service:

[Unit]
Description=Noctora Nightwatch agent
After=network.target
[Service]
User=www-data
WorkingDirectory=/path/to/your-app
ExecStart=/usr/bin/php /path/to/your-app/artisan nightwatch:agent
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target

Use the full path to PHP (which php shows it). Then start it and enable it at boot:

Terminal window
sudo systemctl enable --now nightwatch-agent
sudo systemctl status nightwatch-agent
journalctl -u nightwatch-agent -f

Restart it with sudo systemctl restart nightwatch-agent.

In your site’s environment settings, add:

NIGHTWATCH_TOKEN=your-environment-token
NIGHTWATCH_BASE_URL=https://noctora.spectivis.com/app

On the server’s daemons page, add a daemon with the command php artisan nightwatch:agent, your site’s directory (for example /home/forge/your-site.com) and the user the site runs as. Forge starts it and keeps it running.

To report deploys, add this to the end of your deploy script:

Terminal window
$FORGE_PHP artisan nightwatch:deploy

See Other records for what Noctora does with deployments.

Run the agent as its own service from the same image as your app. Every container that runs your app’s code sends to it over the network.

services:
app:
image: your-app
environment:
NIGHTWATCH_TOKEN: your-environment-token
NIGHTWATCH_INGEST_URI: nightwatch-agent:2407
queue:
image: your-app
command: php artisan queue:work
environment:
NIGHTWATCH_TOKEN: your-environment-token
NIGHTWATCH_INGEST_URI: nightwatch-agent:2407
nightwatch-agent:
image: your-app
command: php artisan nightwatch:agent --listen-on=0.0.0.0:2407
restart: unless-stopped
environment:
NIGHTWATCH_TOKEN: your-environment-token
NIGHTWATCH_BASE_URL: https://noctora.spectivis.com/app
  • The agent listens on port 2407 and signs in with the token and base URL.
  • Every container that runs your app’s code, whether web, queue worker or scheduler, sets NIGHTWATCH_INGEST_URI to the agent’s address. By default the package sends to 127.0.0.1:2407, which inside a container is the container itself.
  • Every container uses the same NIGHTWATCH_TOKEN.

Don’t publish port 2407 outside the Docker network. From an app container, php artisan nightwatch:status checks that the app reaches the agent. The same layout works in Docker Swarm, Kubernetes and similar: one agent service per Environment.

The platform has to give you a process that runs all the time, and a network path from your app to it. If it runs background workers next to the web process, run the agent as one and follow the Docker layout.

On function-based platforms, where each request runs in a short-lived function, the agent has nowhere to keep running. Either run the agent on an always-on machine or container in the same private network and point NIGHTWATCH_INGEST_URI at it, or run that part of your app on a server or in containers. Keep the agent’s port private.

To turn monitoring off in an environment such as local development or CI, set NIGHTWATCH_ENABLED=false.

The agent reads NIGHTWATCH_BASE_URL from its process environment. Laravel copies .env into that environment, but not once you’ve run php artisan config:cache or php artisan optimize. Then the agent ignores the .env value and tries to send to Laravel Nightwatch instead of Noctora.

Set the base URL on the process itself. Under Supervisor, add this line to the program:

environment=NIGHTWATCH_BASE_URL="https://noctora.spectivis.com/app"

Under systemd, add this to the [Service] section, then run sudo systemctl daemon-reload && sudo systemctl restart nightwatch-agent:

Environment=NIGHTWATCH_BASE_URL=https://noctora.spectivis.com/app

On Forge, start the daemon with env NIGHTWATCH_BASE_URL=https://noctora.spectivis.com/app php artisan nightwatch:agent. php artisan nightwatch:deploy reads the variable the same way, so set it for your deploy script too.

Each Environment has its own token, and the token decides where data goes. Give each deployment the token of its own Environment, and the same NIGHTWATCH_BASE_URL:

# production .env
NIGHTWATCH_TOKEN=production-environment-token
# staging .env
NIGHTWATCH_TOKEN=staging-environment-token

Don’t share a token between deployments, or their data mixes in one Environment. Owners and Admins add Environments from the Application on the Organization’s Applications tab, and create each one’s token on its Settings page.

© 2026 Spectivis Technologies Inc.TermsPrivacyRefundsAcceptable use