Skip to content

Provisioning Console

When a new tenant registers (and completes payment, if required), the SaaS module runs a provisioning pipeline that creates the tenant record, database, and seed data. The Provisioning Console shows this process in real time via a terminal-style UI.


How It Works

  1. After successful registration (or payment verification), the system creates a provisioning process and redirects the user to the console page.
  2. The browser sends a POST to the start endpoint, which runs the entire pipeline synchronously with ignore_user_abort(true).
  3. A separate polling loop (GET every 800 ms) fetches new log lines and renders them in the terminal panel.
  4. When provisioning completes (or fails), the console displays the final status and auto-redirects to the success page.

Routes

MethodURIName
GET/tenant/register/setup/{id}saas.provisioning.console
POST/tenant/register/setup/{id}/startsaas.provisioning.console.start
GET/tenant/register/setup/{id}/pollsaas.provisioning.console.poll

Pipeline Steps

The console logs each step with coloured output:

StepDescriptionProgress
Tenant recordCreate tenants row and domain5–10 %
Database setupCreate dedicated DB (separate mode) or skip (single mode)12–18 %
Tenancy contextInitialize Stancl tenancy for the new tenant20–22 %
StorageCreate tenant storage directories23–25 %
Migrations & seedingRun all tenant migrations and seeders with per-file logging27–98 %
DoneEnd tenancy, update status, redirect100 %

If any step fails, partial resources (tenant record, database, domain) are automatically rolled back so the user can safely retry.


Enable / Disable

The console is controlled by a SaaS setting:

SettingDefault
provisioning_console_enabledtrue

When disabled, the registration flow shows a simple progress spinner instead of the terminal output. The provisioning still runs the same pipeline — only the UI changes.

Toggle this in SaaS Admin → Settings or via the SAAS_PROVISIONING_CONSOLE_ENABLED environment variable.


Idle Detection

If no new log lines arrive for 90 seconds while the status is still running, the console displays a warning:

Still running — a database setup step is in progress. Please wait…

This prevents users from thinking the process is frozen during long migration or seeding operations.


Troubleshooting

SymptomLikely CauseFix
Console shows "Setup session expired"Process UUID expired (2-hour TTL) or file was deletedRe-register; check storage/app/provisioning-console/
Console hangs on "Starting…"PHP worker exhausted or max_execution_time too lowSet max_execution_time=0 in php.ini for CLI; ensure Apache/Nginx has multiple workers
Logs appear all at onceFile I/O contention on the log fileEnsure storage/app/provisioning-console/ is on a fast local disk
Progress bar stops mid-waySeeder or migration threw an exceptionCheck storage/logs/laravel.log for the stack trace; the console should show the error message
Subdomain "was taken" errorRace condition — another registration claimed itUser should try a different subdomain